// Note array_intersect() preserves keys from the first arg, and we're
// assuming $revQuery has `revision` primary and isn't using subtables
// for anything we care about.
- $tablesFlat = [];
- array_walk_recursive(
- $revQuery['tables'],
- function ( $a ) use ( &$tablesFlat ) {
- $tablesFlat[] = $a;
- }
- );
-
$res = $dbw->select(
array_intersect(
- $tablesFlat,
+ $revQuery['tables'],
[ 'revision', 'revision_comment_temp', 'revision_actor_temp' ]
),
'1',
$updater->setUndidRevisionId( $current->getId() );
$updater->addTags( $tags );
+ // TODO: this logic should not be in the storage layer, it's here for compatibility
+ // with 1.31 behavior. Applying the 'autopatrol' right should be done in the same
+ // place the 'bot' right is handled, which is currently in EditPage::attemptSave.
+ if ( $wgUseRCPatrol && $this->getTitle()->userCan( 'autopatrol', $guser ) ) {
+ $updater->setRcPatrolStatus( RecentChange::PRC_AUTOPATROLLED );
+ }
+
// Actually store the rollback
$rev = $updater->saveRevision(
CommentStoreComment::newUnsavedComment( $summary ),
*/
public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
$id = $id ?: $this->getId();
- $ns = $this->getTitle()->getNamespace();
+ $type = MWNamespace::getCategoryLinkType( $this->getTitle()->getNamespace() );
$addFields = [ 'cat_pages = cat_pages + 1' ];
$removeFields = [ 'cat_pages = cat_pages - 1' ];
- if ( $ns == NS_CATEGORY ) {
- $addFields[] = 'cat_subcats = cat_subcats + 1';
- $removeFields[] = 'cat_subcats = cat_subcats - 1';
- } elseif ( $ns == NS_FILE ) {
- $addFields[] = 'cat_files = cat_files + 1';
- $removeFields[] = 'cat_files = cat_files - 1';
+ if ( $type !== 'page' ) {
+ $addFields[] = "cat_{$type}s = cat_{$type}s + 1";
+ $removeFields[] = "cat_{$type}s = cat_{$type}s - 1";
}
$dbw = wfGetDB( DB_MASTER );
$insertRows[] = [
'cat_title' => $cat,
'cat_pages' => 1,
- 'cat_subcats' => ( $ns == NS_CATEGORY ) ? 1 : 0,
- 'cat_files' => ( $ns == NS_FILE ) ? 1 : 0,
+ 'cat_subcats' => ( $type === 'subcat' ) ? 1 : 0,
+ 'cat_files' => ( $type === 'file' ) ? 1 : 0,
];
}
$dbw->upsert(