From b1193eec5f581c82153b67ab3c78d1e90422427a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 13 Jul 2011 18:05:44 +0000 Subject: [PATCH] * Broke long Wiki.php lines * Added getValueNames() function to WebRequest.php --- includes/WebRequest.php | 10 ++++++++++ includes/Wiki.php | 26 ++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 621631bdcf..196962c7d3 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -485,6 +485,16 @@ class WebRequest { return $retVal; } + /** + * Returns the names of all input values excluding those in $exclude. + * + * @param $exclude Array + * @return array + */ + public function getValueNames( $exclude = array() ) { + return array_diff( array_keys( $this->getValues() ), $exclude ); + } + /** * Get the values passed in the query string. * No transformation is performed on the values. diff --git a/includes/Wiki.php b/includes/Wiki.php index 99c7aca01e..5b0972eac7 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -80,7 +80,9 @@ class MediaWiki { $ret = Title::newFromURL( $title ); // check variant links so that interwiki links don't have to worry // about the possible different language variants - if ( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ){ + if ( count( $wgContLang->getVariants() ) > 1 + && !is_null( $ret ) && $ret->getArticleID() == 0 ) + { $wgContLang->findVariantLink( $title, $ret ); } } @@ -96,7 +98,7 @@ class MediaWiki { } } - if( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ){ + if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) { $ret = new BadTitle; } return $ret; @@ -162,7 +164,9 @@ class MediaWiki { $url = $title->getFullURL( $query ); } // Check for a redirect loop - if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $title->isLocal() ) { + if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) + && $title->isLocal() ) + { // 301 so google et al report the target as the actual url. $output->redirect( $url, 301 ); } else { @@ -172,8 +176,9 @@ class MediaWiki { } // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted() - && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBKey() != $request->getVal( 'title' ) ) - && !count( array_diff( array_keys( $request->getValues() ), array( 'action', 'title' ) ) ) ) + && ( $request->getVal( 'title' ) === null || + $title->getPrefixedDBKey() != $request->getVal( 'title' ) ) + && !count( $request->getValueNames( array( 'action', 'title' ) ) ) ) { if ( $title->getNamespace() == NS_SPECIAL ) { list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); @@ -482,10 +487,14 @@ class MediaWiki { $section = $request->getVal( 'section' ); $oldid = $request->getVal( 'oldid' ); if ( !$wgUseExternalEditor || $act == 'submit' || $internal || - $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { + $section || $oldid || + ( !$user->getOption( 'externaleditor' ) && !$external ) ) + { $editor = new EditPage( $article ); $editor->submit(); - } elseif ( $wgUseExternalEditor && ( $external || $user->getOption( 'externaleditor' ) ) ) { + } elseif ( $wgUseExternalEditor + && ( $external || $user->getOption( 'externaleditor' ) ) ) + { $mode = $request->getVal( 'mode' ); $extedit = new ExternalEdit( $article, $mode ); $extedit->edit(); @@ -588,7 +597,8 @@ class MediaWiki { $cache = new HTMLFileCache( $wgTitle, $action ); if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) { /* Check incoming headers to see if client has this cached */ - if ( !$this->context->getOutput()->checkLastModified( $cache->fileCacheTime() ) ) { + $timestamp = $cache->fileCacheTime(); + if ( !$this->context->getOutput()->checkLastModified( $timestamp ) ) { $cache->loadFromFileCache(); } # Do any stats increment/watchlist stuff -- 2.20.1