https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112850
Revision: 112850
Author: reedy
Date: 2012-03-01 23:14:43 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
MFT r111427, r112347
Modified Paths:
--------------
branches/wmf/1.19wmf1/docs/hooks.txt
branches/wmf/1.19wmf1/includes/Article.php
branches/wmf/1.19wmf1/includes/filerepo/backend/FSFileBackend.php
Property Changed:
----------------
branches/wmf/1.19wmf1/
branches/wmf/1.19wmf1/includes/
Property changes on: branches/wmf/1.19wmf1
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/JSTesting:100352-107913
/branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/branches/wmf/1.18wmf1:97508,111667
/trunk/phase3:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251,111397,111571,111574,111597,111658,111673,111695,111697,111750,111802-111803,111827,111965-111967,112021,112034,112037,112045-112046,112049,112061-112063,112065-112066,112070-112071,112079,112100,112128,112132-112133,112141,112152,112169-112170,112172-112173,112179,112184,112259,112290,112374,112378,112381,112383,112397,112408,112474,112526,112533-112534,112563,112566,112700,112750,112839-112840,112843
+ /branches/JSTesting:100352-107913
/branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/branches/wmf/1.18wmf1:97508,111667
/trunk/phase3:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251,111397,111427,111571,111574,111597,111658,111673,111695,111697,111750,111802-111803,111827,111965-111967,112021,112034,112037,112045-112046,112049,112061-112063,112065-112066,112070-112071,112079,112100,112128,112132-112133,112141,112152,112169-112170,112172-112173,112179,112184,112259,112290,112347,112374,112378,112381,112383,112397,112408,112474,112526,112533-112534,112563,112566,112700,112750,112839-112840,112843
Modified: branches/wmf/1.19wmf1/docs/hooks.txt
===================================================================
--- branches/wmf/1.19wmf1/docs/hooks.txt 2012-03-01 23:04:44 UTC (rev
112849)
+++ branches/wmf/1.19wmf1/docs/hooks.txt 2012-03-01 23:14:43 UTC (rev
112850)
@@ -587,6 +587,11 @@
Change $bad and return false to override. If an image is "bad", it is not
rendered inline in wiki pages or galleries in category pages.
+'BeforeDisplayNoArticleText': before displaying noarticletext or
noarticletext-nopermission
+at Article::showMissingArticle()
+
+$article: article object
+
'BeforeInitialize': before anything is initialized in
MediaWiki::performRequest()
&$title: Title being used for request
$unused: null
Property changes on: branches/wmf/1.19wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/JSTesting/includes:100352-107913
/branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf/1.18wmf1/includes:97508,111667
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:111029,111034,111067,111085,111128,111144,111251,111397,111571,111574,111597,111658,111673,111695,111697,111750,111827,111965-111967,112021,112045-112046,112049,112061-112063,112065-112066,112070-112071,112079,112128,112132-112133,112152,112184,112259,112290,112374,112378,112381,112383,112397,112408,112474,112526,112534,112563,112700,112839-112840,112843
+ /branches/JSTesting/includes:100352-107913
/branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf/1.18wmf1/includes:97508,111667
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:111029,111034,111067,111085,111128,111144,111251,111397,111427,111571,111574,111597,111658,111673,111695,111697,111750,111827,111965-111967,112021,112045-112046,112049,112061-112063,112065-112066,112070-112071,112079,112128,112132-112133,112152,112184,112259,112290,112347,112374,112378,112381,112383,112397,112408,112474,112526,112534,112563,112700,112839-112840,112843
Modified: branches/wmf/1.19wmf1/includes/Article.php
===================================================================
--- branches/wmf/1.19wmf1/includes/Article.php 2012-03-01 23:04:44 UTC (rev
112849)
+++ branches/wmf/1.19wmf1/includes/Article.php 2012-03-01 23:14:43 UTC (rev
112850)
@@ -988,6 +988,18 @@
'msgKey' => array( 'moveddeleted-notice' ) )
);
+ if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
+ // If there's no backing content, send a 404 Not Found
+ // for better machine handling of broken links.
+ $wgRequest->response()->header( "HTTP/1.1 404 Not
Found" );
+ }
+
+ $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array(
$this ) );
+
+ if ( ! $hookResult ) {
+ return;
+ }
+
# Show error message
$oldid = $this->getOldID();
if ( $oldid ) {
@@ -1010,12 +1022,6 @@
}
$text = "<div class='noarticletext'>\n$text\n</div>";
- if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
- // If there's no backing content, send a 404 Not Found
- // for better machine handling of broken links.
- $wgRequest->response()->header( "HTTP/1.1 404 Not
Found" );
- }
-
$wgOut->addWikiText( $text );
}
Modified: branches/wmf/1.19wmf1/includes/filerepo/backend/FSFileBackend.php
===================================================================
--- branches/wmf/1.19wmf1/includes/filerepo/backend/FSFileBackend.php
2012-03-01 23:04:44 UTC (rev 112849)
+++ branches/wmf/1.19wmf1/includes/filerepo/backend/FSFileBackend.php
2012-03-01 23:14:43 UTC (rev 112850)
@@ -16,7 +16,7 @@
* Sharding can be accomplished by using FileRepo-style hash paths.
*
* Status messages should avoid mentioning the internal FS paths.
- * Likewise, error suppression should be used to avoid path disclosure.
+ * PHP warnings are assumed to be logged rather than output.
*
* @ingroup FileBackend
* @since 1.19
@@ -41,14 +41,13 @@
parent::__construct( $config );
// Remove any possible trailing slash from directories
-
if ( isset( $config['basePath'] ) ) {
$this->basePath = rtrim( $config['basePath'], '/' ); //
remove trailing slash
} else {
$this->basePath = null; // none; containers must have
explicit paths
}
- if( isset( $config['containerPaths'] ) ) {
+ if ( isset( $config['containerPaths'] ) ) {
$this->containerPaths =
(array)$config['containerPaths'];
foreach ( $this->containerPaths as &$path ) {
$path = rtrim( $path, '/' ); // remove
trailing slash
@@ -138,13 +137,11 @@
}
$parentDir = dirname( $fsPath );
- wfSuppressWarnings();
if ( file_exists( $fsPath ) ) {
$ok = is_file( $fsPath ) && is_writable( $fsPath );
} else {
$ok = is_dir( $parentDir ) && is_writable( $parentDir );
}
- wfRestoreWarnings();
return $ok;
}
@@ -163,9 +160,7 @@
if ( file_exists( $dest ) ) {
if ( !empty( $params['overwrite'] ) ) {
- wfSuppressWarnings();
$ok = unlink( $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-delete',
$params['dst'] );
return $status;
@@ -176,9 +171,7 @@
}
}
- wfSuppressWarnings();
$ok = copy( $params['src'], $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-store', $params['src'],
$params['dst'] );
return $status;
@@ -209,9 +202,7 @@
if ( file_exists( $dest ) ) {
if ( !empty( $params['overwrite'] ) ) {
- wfSuppressWarnings();
$ok = unlink( $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-delete',
$params['dst'] );
return $status;
@@ -222,9 +213,7 @@
}
}
- wfSuppressWarnings();
$ok = copy( $source, $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-copy', $params['src'],
$params['dst'] );
return $status;
@@ -257,9 +246,7 @@
if ( !empty( $params['overwrite'] ) ) {
// Windows does not support moving over
existing files
if ( wfIsWindows() ) {
- wfSuppressWarnings();
$ok = unlink( $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal(
'backend-fail-delete', $params['dst'] );
return $status;
@@ -271,10 +258,8 @@
}
}
- wfSuppressWarnings();
$ok = rename( $source, $dest );
clearstatcache(); // file no longer at source
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-move', $params['src'],
$params['dst'] );
return $status;
@@ -302,9 +287,7 @@
return $status; // do nothing; either OK or bad status
}
- wfSuppressWarnings();
$ok = unlink( $source );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-delete', $params['src'] );
return $status;
@@ -327,9 +310,7 @@
if ( file_exists( $dest ) ) {
if ( !empty( $params['overwrite'] ) ) {
- wfSuppressWarnings();
$ok = unlink( $dest );
- wfRestoreWarnings();
if ( !$ok ) {
$status->fatal( 'backend-fail-delete',
$params['dst'] );
return $status;
@@ -340,9 +321,7 @@
}
}
- wfSuppressWarnings();
$bytes = file_put_contents( $dest, $params['content'] );
- wfRestoreWarnings();
if ( $bytes === false ) {
$status->fatal( 'backend-fail-create', $params['dst'] );
return $status;
@@ -381,9 +360,7 @@
$dir = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
// Seed new directories with a blank index.html, to prevent
crawling...
if ( !empty( $params['noListing'] ) && !file_exists(
"{$dir}/index.html" ) ) {
- wfSuppressWarnings();
$bytes = file_put_contents( "{$dir}/index.html", '' );
- wfRestoreWarnings();
if ( !$bytes ) {
$status->fatal( 'backend-fail-create',
$params['dir'] . '/index.html' );
return $status;
@@ -392,9 +369,7 @@
// Add a .htaccess file to the root of the container...
if ( !empty( $params['noAccess'] ) ) {
if ( !file_exists( "{$contRoot}/.htaccess" ) ) {
- wfSuppressWarnings();
$bytes = file_put_contents(
"{$contRoot}/.htaccess", "Deny from all\n" );
- wfRestoreWarnings();
if ( !$bytes ) {
$storeDir =
"mwstore://{$this->name}/{$shortCont}";
$status->fatal( 'backend-fail-create',
"{$storeDir}/.htaccess" );
@@ -430,7 +405,7 @@
return false; // invalid storage path
}
- $this->trapWarnings();
+ $this->trapWarnings(); // don't trust 'false' if there were
errors
$stat = is_file( $source ) ? stat( $source ) : false; //
regular files only
$hadError = $this->untrapWarnings();
@@ -460,16 +435,12 @@
list( $b, $shortCont, $r ) = FileBackend::splitStoragePath(
$params['dir'] );
$contRoot = $this->containerFSRoot( $shortCont, $fullCont ); //
must be valid
$dir = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
- wfSuppressWarnings();
$exists = is_dir( $dir );
- wfRestoreWarnings();
if ( !$exists ) {
wfDebug( __METHOD__ . "() given directory does not
exist: '$dir'\n" );
return array(); // nothing under this dir
}
- wfSuppressWarnings();
$readable = is_readable( $dir );
- wfRestoreWarnings();
if ( !$readable ) {
wfDebug( __METHOD__ . "() given directory is
unreadable: '$dir'\n" );
return null; // bad permissions?
@@ -506,9 +477,7 @@
$tmpPath = $tmpFile->getPath();
// Copy the source file over the temp file
- wfSuppressWarnings();
$ok = copy( $source, $tmpPath );
- wfRestoreWarnings();
if ( !$ok ) {
return null;
}
@@ -533,17 +502,18 @@
}
/**
- * Suppress E_WARNING errors and track whether any happen
+ * Listen for E_WARNING errors and track whether any happen
*
- * @return void
+ * @return bool
*/
protected function trapWarnings() {
$this->hadWarningErrors[] = false; // push to stack
set_error_handler( array( $this, 'handleWarning' ), E_WARNING );
+ return false; // invoke normal PHP error handler
}
/**
- * Unsuppress E_WARNING errors and return true if any happened
+ * Stop listening for E_WARNING errors and return true if any happened
*
* @return bool
*/
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs