From 7142afaba0d9e1915e7ff7d4d2fbb3a1b0dcd040 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 2 May 2013 03:27:58 +0200 Subject: [PATCH] resourceloader: Write to debug log for all fatal errors There's various fatal errors that can happen in ResourceLoader. Since in a javascript/css response there is no error page we can show, we currently catch them all and output them in a block comment on top of load.php. This maintains valid syntax for the response and keeps the error easy to view (if you're looking for it in the browser). However from a debugging perspective it is a nightmare. Literally the only visible difference from a normal request response is the cache maxage (if hasErrors: use unversionsed maxage). For all errors we currently already catch and write to request response outpout, also write to debug log. This also helps in fixing bug #. This commit basically changes the following pattern: // Add exception to the output as a comment $errors .= $this->makeComment( $e->__toString() ); $this->hasErrors = true; to: wfDebugLog( 'resourceloader', __METHOD__ . ": : $e\n" ); $this->hasErrors = true; // Add exception to the output as a comment $errors .= $this->makeComment( $e->__toString() ); Bug: 44018 Change-Id: I684f6492f839a6c6adb07b0640e88cfea21fcf60 --- includes/resourceloader/ResourceLoader.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index a3c3b10251..e4fd982ece 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -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__ ); @@ -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; @@ -467,9 +471,10 @@ class ResourceLoader { try { $this->preloadModuleInfo( array_keys( $modules ), $context ); } 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; } } @@ -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; -- 2.20.1