Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index c078e90..e86f292 100644 (file)
@@ -583,9 +583,9 @@ class LocalFile extends File {
                        ->getComment( 'description', (object)$decoded )->text;
 
                $decoded['user'] = User::newFromAnyId(
-                       isset( $decoded['user'] ) ? $decoded['user'] : null,
-                       isset( $decoded['user_text'] ) ? $decoded['user_text'] : null,
-                       isset( $decoded['actor'] ) ? $decoded['actor'] : null
+                       $decoded['user'] ?? null,
+                       $decoded['user_text'] ?? null,
+                       $decoded['actor'] ?? null
                );
                unset( $decoded['user_text'], $decoded['actor'] );
 
@@ -772,9 +772,9 @@ class LocalFile extends File {
 
                if ( isset( $info['user'] ) || isset( $info['user_text'] ) || isset( $info['actor'] ) ) {
                        $this->user = User::newFromAnyId(
-                               isset( $info['user'] ) ? $info['user'] : null,
-                               isset( $info['user_text'] ) ? $info['user_text'] : null,
-                               isset( $info['actor'] ) ? $info['actor'] : null
+                               $info['user'] ?? null,
+                               $info['user_text'] ?? null,
+                               $info['actor'] ?? null
                        );
                }
 
@@ -1300,11 +1300,14 @@ class LocalFile extends File {
         * @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();
@@ -1361,7 +1364,8 @@ class LocalFile extends File {
                                $props,
                                $timestamp,
                                $user,
-                               $tags
+                               $tags,
+                               $createNullRevision
                        );
                        if ( !$uploadStatus->isOK() ) {
                                if ( $uploadStatus->hasMessage( 'filenotfound' ) ) {
@@ -1419,10 +1423,13 @@ class LocalFile extends File {
         * @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;
 
@@ -1662,7 +1669,7 @@ class LocalFile extends File {
                        $formatter->setContext( RequestContext::newExtraneousContext( $descTitle ) );
                        $editSummary = $formatter->getPlainActionText();
 
-                       $nullRevision = Revision::newNullRevision(
+                       $nullRevision = $createNullRevision === false ? null : Revision::newNullRevision(
                                $dbw,
                                $descId,
                                $editSummary,
@@ -2201,7 +2208,7 @@ class LocalFile extends File {
 
                // If extra data (metadata) was not loaded then it must have been large
                return $this->extraDataLoaded
-               && strlen( serialize( $this->metadata ) ) <= self::CACHE_FIELD_MAX_LEN;
+                       && strlen( serialize( $this->metadata ) ) <= self::CACHE_FIELD_MAX_LEN;
        }
 
        /**
@@ -2209,9 +2216,9 @@ class LocalFile extends File {
         * @since 1.28
         */
        public function acquireFileLock() {
-               return $this->getRepo()->getBackend()->lockFiles(
+               return Status::wrap( $this->getRepo()->getBackend()->lockFiles(
                        [ $this->getPath() ], LockManager::LOCK_EX, 10
-               );
+               ) );
        }
 
        /**
@@ -2219,9 +2226,9 @@ class LocalFile extends File {
         * @since 1.28
         */
        public function releaseFileLock() {
-               return $this->getRepo()->getBackend()->unlockFiles(
+               return Status::wrap( $this->getRepo()->getBackend()->unlockFiles(
                        [ $this->getPath() ], LockManager::LOCK_EX
-               );
+               ) );
        }
 
        /**