From: jenkins-bot Date: Tue, 15 May 2018 07:31:09 +0000 (+0000) Subject: Merge "Add setting to control the creation of NullRevision on upload" X-Git-Tag: 1.34.0-rc.0~5431 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=f93af41d4528bae0a4b0a1c791682e39686c2bdf;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Add setting to control the creation of NullRevision on upload" --- f93af41d4528bae0a4b0a1c791682e39686c2bdf diff --combined includes/filerepo/file/LocalFile.php index c078e90dfd,a213633472..1702264045 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@@ -226,7 -226,7 +226,7 @@@ class LocalFile extends File 'img_actor' => $wgActorTableSchemaMigrationStage > MIGRATION_OLD ? 'img_actor' : null, 'img_timestamp', 'img_sha1', - ] + CommentStore::getStore()->getFields( 'img_description' ); + ] + MediaWikiServices::getInstance()->getCommentStore()->getFields( 'img_description' ); } /** @@@ -241,7 -241,7 +241,7 @@@ * - joins: (array) to include in the `$join_conds` to `IDatabase->select()` */ public static function getQueryInfo( array $options = [] ) { - $commentQuery = CommentStore::getStore()->getJoin( 'img_description' ); + $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'img_description' ); $actorQuery = ActorMigration::newMigration()->getJoin( 'img_user' ); $ret = [ 'tables' => [ 'image' ] + $commentQuery['tables'] + $actorQuery['tables'], @@@ -323,7 -323,7 +323,7 @@@ return; } - $cache = ObjectCache::getMainWANInstance(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $cachedValues = $cache->getWithSetCallback( $key, $cache::TTL_WEEK, @@@ -388,7 -388,7 +388,7 @@@ $this->repo->getMasterDB()->onTransactionPreCommitOrIdle( function () use ( $key ) { - ObjectCache::getMainWANInstance()->delete( $key ); + MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key ); }, __METHOD__ ); @@@ -579,7 -579,7 +579,7 @@@ function decodeRow( $row, $prefix = 'img_' ) { $decoded = $this->unprefixRow( $row, $prefix ); - $decoded['description'] = CommentStore::getStore() + $decoded['description'] = MediaWikiServices::getInstance()->getCommentStore() ->getComment( 'description', (object)$decoded )->text; $decoded['user'] = User::newFromAnyId( @@@ -1300,11 -1300,14 +1300,14 @@@ * @param User|null $user User object or null to use $wgUser * @param string[] $tags Change tags to add to the log entry and page revision. * (This doesn't check $user's permissions.) + * @param bool $createNullRevision Set to false to avoid creation of a null revision on file + * upload, see T193621 * @return Status On success, the value member contains the * archive name, or an empty string if it was a new file. */ function upload( $src, $comment, $pageText, $flags = 0, $props = false, - $timestamp = false, $user = null, $tags = [] + $timestamp = false, $user = null, $tags = [], + $createNullRevision = true ) { if ( $this->getRepo()->getReadOnlyReason() !== false ) { return $this->readOnlyFatalStatus(); @@@ -1321,7 -1324,7 +1324,7 @@@ ) { $props = $this->repo->getFileProps( $srcPath ); } else { - $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() ); + $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() ); $props = $mwProps->getPropsFromPath( $srcPath, true ); } } @@@ -1361,7 -1364,8 +1364,8 @@@ $props, $timestamp, $user, - $tags + $tags, + $createNullRevision ); if ( !$uploadStatus->isOK() ) { if ( $uploadStatus->hasMessage( 'filenotfound' ) ) { @@@ -1419,10 -1423,13 +1423,13 @@@ * @param string|bool $timestamp * @param null|User $user * @param string[] $tags + * @param bool $createNullRevision Set to false to avoid creation of a null revision on file + * upload, see T193621 * @return Status */ function recordUpload2( - $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [] + $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [], + $createNullRevision = true ) { global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage; @@@ -1462,7 -1469,7 +1469,7 @@@ # Test to see if the row exists using INSERT IGNORE # This avoids race conditions by locking the row until the commit, and also # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition. - $commentStore = CommentStore::getStore(); + $commentStore = MediaWikiServices::getInstance()->getCommentStore(); list( $commentFields, $commentCallback ) = $commentStore->insertWithTempTable( $dbw, 'img_description', $comment ); $actorMigration = ActorMigration::newMigration(); @@@ -1662,7 -1669,7 +1669,7 @@@ $formatter->setContext( RequestContext::newExtraneousContext( $descTitle ) ); $editSummary = $formatter->getPlainActionText(); - $nullRevision = Revision::newNullRevision( + $nullRevision = $createNullRevision === false ? null : Revision::newNullRevision( $dbw, $descId, $editSummary, @@@ -2470,7 -2477,7 +2477,7 @@@ class LocalFileDeleteBatch $now = time(); $dbw = $this->file->repo->getMasterDB(); - $commentStore = CommentStore::getStore(); + $commentStore = MediaWikiServices::getInstance()->getCommentStore(); $actorMigration = ActorMigration::newMigration(); $encTimestamp = $dbw->addQuotes( $dbw->timestamp( $now ) ); @@@ -2830,7 -2837,7 +2837,7 @@@ class LocalFileRestoreBatch $dbw = $this->file->repo->getMasterDB(); - $commentStore = CommentStore::getStore(); + $commentStore = MediaWikiServices::getInstance()->getCommentStore(); $actorMigration = ActorMigration::newMigration(); $status = $this->file->repo->newGood();