Merge "registration: Avoid redundant LBYL check in ExtensionRegistry::queue()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 5 Sep 2019 18:07:25 +0000 (18:07 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 5 Sep 2019 18:07:25 +0000 (18:07 +0000)
includes/registration/ExtensionRegistry.php
tests/phpunit/includes/registration/ExtensionRegistryTest.php

index 07fe318..c5d4b4a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Composer\Semver\Semver;
+use Wikimedia\AtEase\AtEase;
 use Wikimedia\ScopedCallback;
 use MediaWiki\Shell\Shell;
 use MediaWiki\ShellDisabledError;
@@ -126,15 +127,13 @@ class ExtensionRegistry {
 
                $mtime = $wgExtensionInfoMTime;
                if ( $mtime === false ) {
-                       if ( file_exists( $path ) ) {
-                               $mtime = filemtime( $path );
-                       } else {
-                               throw new Exception( "$path does not exist!" );
-                       }
+                       AtEase::suppressWarnings();
+                       $mtime = filemtime( $path );
+                       AtEase::restoreWarnings();
                        // @codeCoverageIgnoreStart
                        if ( $mtime === false ) {
                                $err = error_get_last();
-                               throw new Exception( "Couldn't stat $path: {$err['message']}" );
+                               throw new Exception( "Unable to open file $path: {$err['message']}" );
                                // @codeCoverageIgnoreEnd
                        }
                }
index 5de1b0c..106cca3 100644 (file)
@@ -19,7 +19,7 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
                $path = __DIR__ . '/doesnotexist.json';
                $this->setExpectedException(
                        Exception::class,
-                       "$path does not exist!"
+                       "file $path"
                );
                $registry->queue( $path );
        }