Collapse some nested if statements
[lhc/web/wiklou.git] / includes / libs / filebackend / FileBackendMultiWrite.php
index 9c367af..f92d5fa 100644 (file)
@@ -87,20 +87,13 @@ class FileBackendMultiWrite extends FileBackend {
         *                      This will apply such updates post-send for web requests. Note that
         *                      any checks from "syncChecks" are still synchronous.
         *
-        * Bogus warning
-        * @suppress PhanAccessMethodProtected
-        *
         * @param array $config
         * @throws FileBackendError
         */
        public function __construct( array $config ) {
                parent::__construct( $config );
-               $this->syncChecks = isset( $config['syncChecks'] )
-                       ? $config['syncChecks']
-                       : self::CHECK_SIZE;
-               $this->autoResync = isset( $config['autoResync'] )
-                       ? $config['autoResync']
-                       : false;
+               $this->syncChecks = $config['syncChecks'] ?? self::CHECK_SIZE;
+               $this->autoResync = $config['autoResync'] ?? false;
                $this->asyncWrites = isset( $config['replication'] ) && $config['replication'] === 'async';
                // Construct backends here rather than via registration
                // to keep these backends hidden from outside the proxy.
@@ -264,11 +257,11 @@ class FileBackendMultiWrite extends FileBackend {
                                                $status->fatal( 'backend-fail-synced', $path );
                                                continue;
                                        }
-                                       if ( $this->syncChecks & self::CHECK_SIZE ) {
-                                               if ( $cStat['size'] != $mStat['size'] ) { // wrong size
-                                                       $status->fatal( 'backend-fail-synced', $path );
-                                                       continue;
-                                               }
+                                       if ( ( $this->syncChecks & self::CHECK_SIZE )
+                                               && $cStat['size'] != $mStat['size']
+                                       ) { // wrong size
+                                               $status->fatal( 'backend-fail-synced', $path );
+                                               continue;
                                        }
                                        if ( $this->syncChecks & self::CHECK_TIME ) {
                                                $mTs = wfTimestamp( TS_UNIX, $mStat['mtime'] );
@@ -278,16 +271,12 @@ class FileBackendMultiWrite extends FileBackend {
                                                        continue;
                                                }
                                        }
-                                       if ( $this->syncChecks & self::CHECK_SHA1 ) {
-                                               if ( $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
-                                                       $status->fatal( 'backend-fail-synced', $path );
-                                                       continue;
-                                               }
-                                       }
-                               } else { // file is not in master
-                                       if ( $cStat ) { // file should not exist
+                                       if ( ( $this->syncChecks & self::CHECK_SHA1 ) && $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
                                                $status->fatal( 'backend-fail-synced', $path );
+                                               continue;
                                        }
+                               } elseif ( $cStat ) { // file is not in master; file should not exist
+                                       $status->fatal( 'backend-fail-synced', $path );
                                }
                        }
                }