r92071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92070‎ | r92071 | r92072 >
Date:18:05, 13 July 2011
Author:aaron
Status:ok
Tags:
Comment:
* Broke long Wiki.php lines
* Added getValueNames() function to WebRequest.php
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -486,6 +486,16 @@
487487 }
488488
489489 /**
 490+ * Returns the names of all input values excluding those in $exclude.
 491+ *
 492+ * @param $exclude Array
 493+ * @return array
 494+ */
 495+ public function getValueNames( $exclude = array() ) {
 496+ return array_diff( array_keys( $this->getValues() ), $exclude );
 497+ }
 498+
 499+ /**
490500 * Get the values passed in the query string.
491501 * No transformation is performed on the values.
492502 *
Index: trunk/phase3/includes/Wiki.php
@@ -80,7 +80,9 @@
8181 $ret = Title::newFromURL( $title );
8282 // check variant links so that interwiki links don't have to worry
8383 // about the possible different language variants
84 - if ( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ){
 84+ if ( count( $wgContLang->getVariants() ) > 1
 85+ && !is_null( $ret ) && $ret->getArticleID() == 0 )
 86+ {
8587 $wgContLang->findVariantLink( $title, $ret );
8688 }
8789 }
@@ -96,7 +98,7 @@
9799 }
98100 }
99101
100 - if( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ){
 102+ if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) {
101103 $ret = new BadTitle;
102104 }
103105 return $ret;
@@ -162,7 +164,9 @@
163165 $url = $title->getFullURL( $query );
164166 }
165167 // Check for a redirect loop
166 - if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $title->isLocal() ) {
 168+ if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url )
 169+ && $title->isLocal() )
 170+ {
167171 // 301 so google et al report the target as the actual url.
168172 $output->redirect( $url, 301 );
169173 } else {
@@ -172,8 +176,9 @@
173177 }
174178 // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
175179 } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
176 - && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBKey() != $request->getVal( 'title' ) )
177 - && !count( array_diff( array_keys( $request->getValues() ), array( 'action', 'title' ) ) ) )
 180+ && ( $request->getVal( 'title' ) === null ||
 181+ $title->getPrefixedDBKey() != $request->getVal( 'title' ) )
 182+ && !count( $request->getValueNames( array( 'action', 'title' ) ) ) )
178183 {
179184 if ( $title->getNamespace() == NS_SPECIAL ) {
180185 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
@@ -482,10 +487,14 @@
483488 $section = $request->getVal( 'section' );
484489 $oldid = $request->getVal( 'oldid' );
485490 if ( !$wgUseExternalEditor || $act == 'submit' || $internal ||
486 - $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) {
 491+ $section || $oldid ||
 492+ ( !$user->getOption( 'externaleditor' ) && !$external ) )
 493+ {
487494 $editor = new EditPage( $article );
488495 $editor->submit();
489 - } elseif ( $wgUseExternalEditor && ( $external || $user->getOption( 'externaleditor' ) ) ) {
 496+ } elseif ( $wgUseExternalEditor
 497+ && ( $external || $user->getOption( 'externaleditor' ) ) )
 498+ {
490499 $mode = $request->getVal( 'mode' );
491500 $extedit = new ExternalEdit( $article, $mode );
492501 $extedit->edit();
@@ -588,7 +597,8 @@
589598 $cache = new HTMLFileCache( $wgTitle, $action );
590599 if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
591600 /* Check incoming headers to see if client has this cached */
592 - if ( !$this->context->getOutput()->checkLastModified( $cache->fileCacheTime() ) ) {
 601+ $timestamp = $cache->fileCacheTime();
 602+ if ( !$this->context->getOutput()->checkLastModified( $timestamp ) ) {
593603 $cache->loadFromFileCache();
594604 }
595605 # Do any stats increment/watchlist stuff

Status & tagging log