if ( '' == $title && 'delete' != $action ) {
- $ret = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+ $ret = Title::newMainPage();
} elseif ( $curid = $request->getInt( 'curid' ) ) {
# URLs like this are generated by RC, because rc_title isn't always accurate
$ret = Title::newFromID( $curid );
if( !is_null( $search ) && $search !== '' ) {
// Compatibility with old search URLs which didn't use Special:Search
// Do this above the read whitelist check for security...
- $title = Title::makeTitle( NS_SPECIAL, 'Search' );
+ $title = SpecialPage::getTitleFor( 'Search' );
}
$this->setVal( 'Search', $search );
$action = $this->getVal('Action');
if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) {
require_once( 'includes/SpecialSearch.php' );
- $title = Title::makeTitle( NS_SPECIAL, 'Search' );
+ $title = SpecialPage::getTitleFor( 'Search' );
wfSpecialSearch();
} else if( !$title or $title->getDBkey() == '' ) {
- $title = Title::makeTitle( NS_SPECIAL, 'Badtitle' );
+ $title = SpecialPage::getTitleFor( 'Badtitle' );
# Die now before we mess up $wgArticle and the skin stops working
throw new ErrorPageError( 'badtitle', 'badtitletext' );
} else if ( $title->getInterwiki() != '' ) {
if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
$output->redirect( $url );
} else {
- $title = Title::makeTitle( NS_SPECIAL, 'Badtitle' );
+ $title = SpecialPage::getTitleFor( 'Badtitle' );
throw new ErrorPageError( 'badtitle', 'badtitletext' );
}
} else if ( ( $action == 'view' ) &&
(!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
!count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
{
- /* Redirect to canonical url, make it a 301 to allow caching */
- $output->setSquidMaxage( 1200 );
- $output->redirect( $title->getFullURL(), '301');
+ $targetUrl = $title->getFullURL();
+ // Redirect to canonical url, make it a 301 to allow caching
+ global $wgServer, $wgUsePathInfo;
+ if( isset( $_SERVER['REQUEST_URI'] ) &&
+ $targetUrl == $wgServer . $_SERVER['REQUEST_URI'] ) {
+ $message = "Redirect loop detected!\n\n" .
+ "This means the wiki got confused about what page was " .
+ "requested; this sometimes happens when moving a wiki " .
+ "to a new server or changing the server configuration.\n\n";
+
+ if( $wgUsePathInfo ) {
+ $message .= "The wiki is trying to interpret the page " .
+ "title from the URL path portion (PATH_INFO), which " .
+ "sometimes fails depending on the web server. Try " .
+ "setting \"\$wgUsePathInfo = false;\" in your " .
+ "LocalSettings.php, or check that \$wgArticlePath " .
+ "is correct.";
+ } else {
+ $message .= "Your web server was detected as possibly not " .
+ "supporting URL path components (PATH_INFO) correctly; " .
+ "check your LocalSettings.php for a customized " .
+ "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
+ "to true.";
+ }
+ wfHttpError( 500, "Internal error", $message );
+ return false;
+ } else {
+ $output->setSquidMaxage( 1200 );
+ $output->redirect( $targetUrl, '301');
+ }
} else if ( NS_SPECIAL == $title->getNamespace() ) {
/* actions that need to be made when we have a special pages */
SpecialPage::executePath( $title );
* @return Article
*/
function articleFromTitle( $title ) {
+ $article = null;
+ wfRunHooks('ArticleFromTitle', array( &$title, &$article ) );
+ if ( $article ) {
+ return $article;
+ }
+
if( NS_MEDIA == $title->getNamespace() ) {
// FIXME: where should this go?
$title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
*/
function doUpdates ( &$updates ) {
wfProfileIn( 'MediaWiki::doUpdates' );
+ $dbw =& wfGetDB( DB_MASTER );
foreach( $updates as $up ) {
$up->doUpdate();
+
+ # Commit after every update to prevent lock contention
+ if ( $dbw->trxLevel() ) {
+ $dbw->commit();
+ }
}
wfProfileOut( 'MediaWiki::doUpdates' );
}
* Do a job from the job queue
*/
function doJobs() {
- global $wgJobLogFile, $wgJobRunRate;
+ global $wgJobRunRate;
- if ( $wgJobRunRate <= 0 ) {
+ if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
return;
}
if ( $wgJobRunRate < 1 ) {
while ( $n-- && false != ($job = Job::pop())) {
$output = $job->toString() . "\n";
- if ( !$job->run() ) {
- $output .= "Error: " . $job->getLastError() . "\n";
- }
- if ( $wgJobLogFile ) {
- error_log( $output, 3, $wgJobLogFile );
+ $t = -wfTime();
+ $success = $job->run();
+ $t += wfTime();
+ $t = round( $t*1000 );
+ if ( !$success ) {
+ $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
+ } else {
+ $output .= "Success, Time: $t ms\n";
}
+ wfDebugLog( 'jobqueue', $output );
}
}
* Ends this task peacefully
*/
function restInPeace ( &$loadBalancer ) {
- wfProfileClose();
- logProfilingData();
+ wfLogProfilingData();
$loadBalancer->closeAll();
wfDebug( "Request ended normally\n" );
}