phpcs: More require/include is not a function
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index dd613a7..543bd1d 100644 (file)
@@ -174,9 +174,10 @@ class ResourceLoader {
                        // Save filtered text to Memcached
                        $cache->set( $key, $result );
                } catch ( Exception $exception ) {
+                       wfDebugLog( 'resourceloader', __METHOD__ . ": minification failed: $e" );
+                       $this->hasErrors = true;
                        // Return exception as a comment
                        $result = $this->makeComment( $exception->__toString() );
-                       $this->hasErrors = true;
                }
 
                wfProfileOut( __METHOD__ );
@@ -201,7 +202,7 @@ class ResourceLoader {
                $this->addSource( $wgResourceLoaderSources );
 
                // Register core modules
-               $this->register( include( "$IP/resources/Resources.php" ) );
+               $this->register( include "$IP/resources/Resources.php" );
                // Register extension modules
                wfRunHooks( 'ResourceLoaderRegisterModules', array( &$this ) );
                $this->register( $wgResourceModules );
@@ -283,7 +284,7 @@ class ResourceLoader {
 
                // Get core test suites
                $testModules = array();
-               $testModules['qunit'] = include( "$IP/tests/qunit/QUnitTestResources.php" );
+               $testModules['qunit'] = include "$IP/tests/qunit/QUnitTestResources.php";
                // Get other test suites (e.g. from extensions)
                wfRunHooks( 'ResourceLoaderTestModules', array( &$testModules, &$this ) );
 
@@ -318,7 +319,7 @@ class ResourceLoader {
         * @param array $properties source properties
         * @throws MWException
         */
-       public function addSource( $id, $properties = null) {
+       public function addSource( $id, $properties = null ) {
                // Allow multiple sources to be registered in one call
                if ( is_array( $id ) ) {
                        foreach ( $id as $key => $value ) {
@@ -364,7 +365,7 @@ class ResourceLoader {
         * @return Array
         */
        public function getTestModuleNames( $framework = 'all' ) {
-               /// @TODO: api siteinfo prop testmodulenames modulenames
+               /// @todo api siteinfo prop testmodulenames modulenames
                if ( $framework == 'all' ) {
                        return $this->testModuleNames;
                } elseif ( isset( $this->testModuleNames[$framework] ) && is_array( $this->testModuleNames[$framework] ) ) {
@@ -453,8 +454,11 @@ class ResourceLoader {
                                // Do not allow private modules to be loaded from the web.
                                // This is a security issue, see bug 34907.
                                if ( $module->getGroup() === 'private' ) {
-                                       $errors .= $this->makeComment( "Cannot show private module \"$name\"" );
+                                       wfDebugLog( 'resourceloader', __METHOD__ . ": request for private module denied: $e" );
                                        $this->hasErrors = true;
+                                       // Add exception to the output as a comment
+                                       $errors .= $this->makeComment( "Cannot show private module \"$name\"" );
+
                                        continue;
                                }
                                $modules[$name] = $module;
@@ -466,10 +470,11 @@ class ResourceLoader {
                // Preload information needed to the mtime calculation below
                try {
                        $this->preloadModuleInfo( array_keys( $modules ), $context );
-               } catch( Exception $e ) {
+               } catch ( Exception $e ) {
+                       wfDebugLog( 'resourceloader', __METHOD__ . ": preloading module info failed: $e" );
+                       $this->hasErrors = true;
                        // Add exception to the output as a comment
                        $errors .= $this->makeComment( $e->__toString() );
-                       $this->hasErrors = true;
                }
 
                wfProfileIn( __METHOD__ . '-getModifiedTime' );
@@ -485,9 +490,10 @@ class ResourceLoader {
                                // Calculate maximum modified time
                                $mtime = max( $mtime, $module->getModifiedTime( $context ) );
                        } catch ( Exception $e ) {
+                               wfDebugLog( 'resourceloader', __METHOD__ . ": calculating maximum modified time failed: $e" );
+                               $this->hasErrors = true;
                                // Add exception to the output as a comment
                                $errors .= $this->makeComment( $e->__toString() );
-                               $this->hasErrors = true;
                        }
                }
 
@@ -637,7 +643,7 @@ class ResourceLoader {
                if ( !$good ) {
                        try { // RL always hits the DB on file cache miss...
                                wfGetDB( DB_SLAVE );
-                       } catch( DBConnectionError $e ) { // ...check if we need to fallback to cache
+                       } catch ( DBConnectionError $e ) { // ...check if we need to fallback to cache
                                $good = $fileCache->isCacheGood(); // cache existence check
                        }
                }
@@ -694,9 +700,10 @@ class ResourceLoader {
                        try {
                                $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() );
                        } catch ( Exception $e ) {
+                               wfDebugLog( 'resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" );
+                               $this->hasErrors = true;
                                // Add exception to the output as a comment
                                $exceptions .= $this->makeComment( $e->__toString() );
-                               $this->hasErrors = true;
                        }
                } else {
                        $blobs = array();
@@ -800,9 +807,10 @@ class ResourceLoader {
                                                break;
                                }
                        } catch ( Exception $e ) {
+                               wfDebugLog( 'resourceloader', __METHOD__ . ": generating module package failed: $e" );
+                               $this->hasErrors = true;
                                // Add exception to the output as a comment
                                $exceptions .= $this->makeComment( $e->__toString() );
-                               $this->hasErrors = true;
 
                                // Register module as missing
                                $missing[] = $name;