r81921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81920‎ | r81921 | r81922 >
Date:22:42, 10 February 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.17wmf1/includes/AjaxDispatcher.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/Article.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/BagOStuff.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/DjVuImage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/EditPage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/Export.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/Linker.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/Title.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/db/LoadBalancer.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/diff/DifferenceEngine.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/job/RefreshLinksJob.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/media/SVGMetadataExtractor.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/parser/Parser.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/parser/Parser_LinkHooks.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/parser/Tidy.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/specials/SpecialAllmessages.php (modified) (history)
  • /branches/wmf/1.17wmf1/languages/LanguageConverter.php (modified) (history)
  • /branches/wmf/1.17wmf1/thumb.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/BagOStuff.php
@@ -727,6 +727,7 @@
728728
729729 $handle = $this->getReader();
730730 if ( !$handle ) {
 731+ wfProfileOut( __METHOD__ );
731732 return null;
732733 }
733734
@@ -757,6 +758,7 @@
758759
759760 $handle = $this->getWriter();
760761 if ( !$handle ) {
 762+ wfProfileOut( __METHOD__ );
761763 return false;
762764 }
763765
@@ -773,6 +775,7 @@
774776
775777 $handle = $this->getWriter();
776778 if ( !$handle ) {
 779+ wfProfileOut( __METHOD__ );
777780 return false;
778781 }
779782
@@ -791,6 +794,7 @@
792795 $handle = $this->getWriter();
793796
794797 if ( !$handle ) {
 798+ wfProfileOut( __METHOD__ );
795799 return false;
796800 }
797801
Index: branches/wmf/1.17wmf1/includes/diff/DifferenceEngine.php
@@ -150,6 +150,8 @@
151151 URL=$url2
152152 CONTROL;
153153 echo( $control );
 154+
 155+ wfProfileOut( __METHOD__ );
154156 return;
155157 }
156158
@@ -620,16 +622,20 @@
621623 $this->mCacheHit = true;
622624 // Check if the diff should be hidden from this user
623625 if ( !$this->loadRevisionData() ) {
 626+ wfProfileOut( __METHOD__ );
624627 return false;
625628 } elseif ( $this->mOldRev && !$this->mOldRev->userCan( Revision::DELETED_TEXT ) ) {
 629+ wfProfileOut( __METHOD__ );
626630 return false;
627631 } elseif ( $this->mNewRev && !$this->mNewRev->userCan( Revision::DELETED_TEXT ) ) {
 632+ wfProfileOut( __METHOD__ );
628633 return false;
629634 }
630635 // Short-circuit
631636 if ( $this->mOldRev && $this->mNewRev
632637 && $this->mOldRev->getID() == $this->mNewRev->getID() )
633638 {
 639+ wfProfileOut( __METHOD__ );
634640 return '';
635641 }
636642 // Cacheable?
@@ -757,6 +763,7 @@
758764 wfProfileOut( __METHOD__ . "-shellexec" );
759765 unlink( $tempName1 );
760766 unlink( $tempName2 );
 767+ wfProfileOut( __METHOD__ );
761768 return $difftext;
762769 }
763770
@@ -765,7 +772,9 @@
766773 $nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
767774 $diffs = new Diff( $ota, $nta );
768775 $formatter = new TableDiffFormatter();
769 - return $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ) .
 776+ $difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ) .
 777+ wfProfileOut( __METHOD__ );
 778+ return $difftext;
770779 $this->debug();
771780 }
772781
Index: branches/wmf/1.17wmf1/includes/Article.php
@@ -1893,6 +1893,7 @@
18941894 if ( !$rev ) {
18951895 wfDebug( "Article::replaceSection asked for bogus section (page: " .
18961896 $this->getId() . "; section: $section; edittime: $edittime)\n" );
 1897+ wfProfileOut( __METHOD__ );
18971898 return null;
18981899 }
18991900
@@ -2074,12 +2075,12 @@
20752076 $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
20762077 {
20772078 wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
2078 - wfProfileOut( __METHOD__ );
20792079
20802080 if ( $status->isOK() ) {
20812081 $status->fatal( 'edit-hook-aborted' );
20822082 }
20832083
 2084+ wfProfileOut( __METHOD__ );
20842085 return $status;
20852086 }
20862087
Property changes on: branches/wmf/1.17wmf1/includes/Article.php
___________________________________________________________________
Modified: svn:mergeinfo
20872088 Merged /trunk/phase3/includes/Article.php:r81729,81890-81894,81896-81898,81900
Index: branches/wmf/1.17wmf1/includes/parser/Tidy.php
@@ -118,15 +118,13 @@
119119 $retval = -1;
120120 }
121121
122 - wfProfileOut( __METHOD__ );
123 -
124122 if( !$stderr && $cleansource == '' && $text != '' ) {
125123 // Some kind of error happened, so we couldn't get the corrected text.
126124 // Just give up; we'll use the source text and append a warning.
127 - return null;
128 - } else {
129 - return $cleansource;
 125+ $cleansource = null;
130126 }
 127+ wfProfileOut( __METHOD__ );
 128+ return $cleansource;
131129 }
132130
133131 /**
@@ -144,6 +142,7 @@
145143
146144 if( $stderr ) {
147145 $retval = $tidy->getStatus();
 146+ wfProfileOut( __METHOD__ );
148147 return $tidy->errorBuffer;
149148 } else {
150149 $tidy->cleanRepair();
Index: branches/wmf/1.17wmf1/includes/parser/Parser.php
@@ -2424,6 +2424,7 @@
24252425 }
24262426 if ( $stack > 0 ) {
24272427 wfDebug( __METHOD__.": Invalid input; not enough close tags (stack $stack, state $state)\n" );
 2428+ wfProfileOut( __METHOD__ );
24282429 return false;
24292430 }
24302431 wfProfileOut( __METHOD__ );
Property changes on: branches/wmf/1.17wmf1/includes/parser/Parser.php
___________________________________________________________________
Modified: svn:mergeinfo
24312432 Merged /trunk/phase3/includes/parser/Parser.php:r81729,81890-81894,81896-81898,81900
Index: branches/wmf/1.17wmf1/includes/parser/Parser_LinkHooks.php
@@ -265,9 +265,10 @@
266266 if( $return === false ) {
267267 # False (no link) was returned, output plain wikitext
268268 # Build it again as the hook is allowed to modify $paramText
269 - return isset($paramText) ? "[[$titleText|$paramText]]" : "[[$titleText]]";
 269+ $return = isset($paramText) ? "[[$titleText|$paramText]]" : "[[$titleText]]";
270270 }
271271 # Content was returned, return it
 272+ wfProfileOut( __METHOD__ );
272273 return $return;
273274 }
274275
Index: branches/wmf/1.17wmf1/includes/Linker.php
@@ -720,6 +720,7 @@
721721 return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
722722 }
723723 } else {
 724+ wfProfileOut( __METHOD__ );
724725 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
725726 }
726727 }
Index: branches/wmf/1.17wmf1/includes/AjaxDispatcher.php
@@ -133,7 +133,7 @@
134134 }
135135 }
136136
 137+ $wgOut = null;
137138 wfProfileOut( __METHOD__ );
138 - $wgOut = null;
139139 }
140140 }
Index: branches/wmf/1.17wmf1/includes/db/DatabaseIbm_db2.php
@@ -351,6 +351,7 @@
352352 }
353353
354354 if ( strlen( $user ) < 1 ) {
 355+ wfProfileOut( __METHOD__ );
355356 return null;
356357 }
357358
@@ -378,6 +379,8 @@
379380 "Server: $server, Database: $dbName, User: $user, Password: "
380381 . substr( $password, 0, 3 ) . "...\n" );
381382 $this->installPrint( $this->lastError() . "\n" );
 383+
 384+ wfProfileOut( __METHOD__ );
382385 return null;
383386 }
384387
Index: branches/wmf/1.17wmf1/includes/db/LoadBalancer.php
@@ -428,6 +428,7 @@
429429 if ( $i === false ) {
430430 $this->mLastError = 'No working slave server: ' . $this->mLastError;
431431 $this->reportConnectionError( $this->mErrorConnection );
 432+ wfProfileOut( __METHOD__ );
432433 return false;
433434 }
434435 }
Index: branches/wmf/1.17wmf1/includes/Export.php
@@ -177,8 +177,8 @@
178178 "</id>" .
179179 "</contributor>";
180180 }
 181+ $this->author_list .= "</contributors>";
181182 wfProfileOut( __METHOD__ );
182 - $this->author_list .= "</contributors>";
183183 }
184184
185185 protected function dumpFrom( $cond = '' ) {
Index: branches/wmf/1.17wmf1/includes/EditPage.php
@@ -659,10 +659,10 @@
660660 // Custom edit intro for new sections
661661 $this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' );
662662
663 - wfProfileOut( __METHOD__ );
664 -
665663 // Allow extensions to modify form data
666664 wfRunHooks( 'EditPage::importFormData', array( $this, $request ) );
 665+
 666+ wfProfileOut( __METHOD__ );
667667 }
668668
669669 /**
@@ -788,6 +788,8 @@
789789
790790 if ( !wfRunHooks( 'EditPage::attemptSave', array( $this ) ) ) {
791791 wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
 792+ wfProfileOut( __METHOD__ . '-checks' );
 793+ wfProfileOut( __METHOD__ );
792794 return self::AS_HOOK_ERROR;
793795 }
794796
@@ -795,11 +797,12 @@
796798 if ( $this->mTitle->getNamespace() == NS_FILE &&
797799 Title::newFromRedirect( $this->textbox1 ) instanceof Title &&
798800 !$wgUser->isAllowed( 'upload' ) ) {
799 - if ( $wgUser->isAnon() ) {
800 - return self::AS_IMAGE_REDIRECT_ANON;
801 - } else {
802 - return self::AS_IMAGE_REDIRECT_LOGGED;
803 - }
 801+ $isAnon = $wgUser->isAnon();
 802+
 803+ wfProfileOut( __METHOD__ . '-checks' );
 804+ wfProfileOut( __METHOD__ );
 805+
 806+ return $isAnon ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
804807 }
805808
806809 # Check for spam
@@ -1220,8 +1223,10 @@
12211224 # Enabled article-related sidebar, toplinks, etc.
12221225 $wgOut->setArticleRelated( true );
12231226
1224 - if ( $this->showHeader() === false )
 1227+ if ( $this->showHeader() === false ) {
 1228+ wfProfileOut( __METHOD__ );
12251229 return;
 1230+ }
12261231
12271232 $action = htmlspecialchars( $this->getActionURL( $wgTitle ) );
12281233
@@ -1873,8 +1878,10 @@
18741879 if ( $wgRawHtml && !$this->mTokenOk ) {
18751880 // Could be an offsite preview attempt. This is very unsafe if
18761881 // HTML is enabled, as it could be an attack.
1877 - return $wgOut->parse( "<div class='previewnote'>" .
 1882+ $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
18781883 wfMsg( 'session_fail_preview_html' ) . "</div>" );
 1884+ wfProfileOut( __METHOD__ );
 1885+ return $parsedNote;
18791886 }
18801887
18811888 # don't parse user css/js, show message about preview
Index: branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoader.php
@@ -443,6 +443,7 @@
444444 return '/* No modules requested. Max made me put this here */';
445445 }
446446
 447+ wfProfileIn( __METHOD__ );
447448 // Pre-fetch blobs
448449 if ( $context->shouldIncludeMessages() ) {
449450 try {
@@ -523,15 +524,16 @@
524525 }
525526 }
526527
527 - if ( $context->getDebug() ) {
528 - return $exceptions . $out;
529 - } else {
 528+ if ( !$context->getDebug() ) {
530529 if ( $context->getOnly() === 'styles' ) {
531 - return $exceptions . $this->filter( 'minify-css', $out );
 530+ $out = $this->filter( 'minify-css', $out );
532531 } else {
533 - return $exceptions . $this->filter( 'minify-js', $out );
 532+ $out = $this->filter( 'minify-js', $out );
534533 }
535534 }
 535+
 536+ wfProfileOut( __METHOD__ );
 537+ return $exceptions . $out;
536538 }
537539
538540 /* Static Methods */
Property changes on: branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
539541 Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r81729,81890-81894,81896-81898,81900
Index: branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoaderFileModule.php
@@ -363,6 +363,7 @@
364364 $this->modifiedTime[$context->getHash()] = max(
365365 $filesMtime,
366366 $this->getMsgBlobMtime( $context->getLanguage() ) );
 367+
367368 wfProfileOut( __METHOD__ );
368369 return $this->modifiedTime[$context->getHash()];
369370 }
Index: branches/wmf/1.17wmf1/includes/media/SVGMetadataExtractor.php
@@ -48,7 +48,7 @@
4949 */
5050 function __construct( $source ) {
5151 $this->reader = new XMLReader();
52 - $this->reader->open( $source );
 52+ $this->reader->open( $source, null, LIBXML_NOERROR | LIBXML_NOWARNING );
5353
5454 $this->metadata['width'] = self::DEFAULT_WIDTH;
5555 $this->metadata['height'] = self::DEFAULT_HEIGHT;
Index: branches/wmf/1.17wmf1/includes/Title.php
@@ -2098,8 +2098,6 @@
20992099 Title::purgeExpiredRestrictions();
21002100 }
21012101
2102 - wfProfileOut( __METHOD__ );
2103 -
21042102 if ( $getPages ) {
21052103 $this->mCascadeSources = $sources;
21062104 $this->mCascadingRestrictions = $pagerestrictions;
@@ -2107,6 +2105,7 @@
21082106 $this->mHasCascadingRestrictions = $sources;
21092107 }
21102108
 2109+ wfProfileOut( __METHOD__ );
21112110 return array( $sources, $pagerestrictions );
21122111 }
21132112
Property changes on: branches/wmf/1.17wmf1/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
21142113 Merged /trunk/phase3/includes/Title.php:r81729,81890-81894,81896-81898,81900
Index: branches/wmf/1.17wmf1/includes/job/RefreshLinksJob.php
@@ -99,6 +99,8 @@
100100 $jobs[] = new RefreshLinksJob( $title, '' );
101101 }
102102 Job::batchInsert( $jobs );
 103+
 104+ wfProfileOut( __METHOD__ );
103105 return true;
104106 }
105107 # Re-parse each page that transcludes this page and update their tracking links...
Index: branches/wmf/1.17wmf1/includes/specials/SpecialAllmessages.php
@@ -202,8 +202,8 @@
203203
204204 // Normalise message names so they look like page titles
205205 $messageNames = array_map( array( $this->lang, 'ucfirst' ), $messageNames );
206 - wfProfileIn( __METHOD__ );
207206
 207+ wfProfileOut( __METHOD__ );
208208 return $messageNames;
209209 }
210210
Index: branches/wmf/1.17wmf1/includes/DjVuImage.php
@@ -226,6 +226,8 @@
227227 */
228228 function retrieveMetaData() {
229229 global $wgDjvuToXML, $wgDjvuDump, $wgDjvuTxt;
 230+ wfProfileIn( __METHOD__ );
 231+
230232 if ( isset( $wgDjvuDump ) ) {
231233 # djvudump is faster as of version 3.5
232234 # http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583
@@ -272,6 +274,7 @@
273275 $xml = $xml . $txt. '</mw-djvu>' ;
274276 }
275277 }
 278+ wfProfileOut( __METHOD__ );
276279 return $xml;
277280 }
278281
Index: branches/wmf/1.17wmf1/thumb.php
@@ -59,11 +59,13 @@
6060 $bits = explode( '!', $fileName, 2 );
6161 if( !isset($bits[1]) ) {
6262 wfThumbError( 404, wfMsg( 'badtitletext' ) );
 63+ wfProfileOut( __METHOD__ );
6364 return;
6465 }
6566 $title = Title::makeTitleSafe( NS_FILE, $bits[1] );
6667 if( is_null($title) ) {
6768 wfThumbError( 404, wfMsg( 'badtitletext' ) );
 69+ wfProfileOut( __METHOD__ );
6870 return;
6971 }
7072 $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
@@ -86,6 +88,7 @@
8789 if ( !$img->getTitle() || !$img->getTitle()->userCanRead() ) {
8890 wfThumbError( 403, 'Access denied. You do not have permission to access ' .
8991 'the source file.' );
 92+ wfProfileOut( __METHOD__ );
9093 return;
9194 }
9295 $headers[] = 'Cache-Control: private';
@@ -94,15 +97,18 @@
9598
9699 if ( !$img ) {
97100 wfThumbError( 404, wfMsg( 'badtitletext' ) );
 101+ wfProfileOut( __METHOD__ );
98102 return;
99103 }
100104 if ( !$img->exists() ) {
101105 wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
 106+ wfProfileOut( __METHOD__ );
102107 return;
103108 }
104109 $sourcePath = $img->getPath();
105110 if ( $sourcePath === false ) {
106111 wfThumbError( 500, 'The source file is not locally accessible.' );
 112+ wfProfileOut( __METHOD__ );
107113 return;
108114 }
109115
@@ -118,6 +124,7 @@
119125 wfRestoreWarnings();
120126 if ( $stat['mtime'] <= $imsUnix ) {
121127 header( 'HTTP/1.1 304 Not Modified' );
 128+ wfProfileOut( __METHOD__ );
122129 return;
123130 }
124131 }
@@ -129,11 +136,13 @@
130137
131138 if ( is_file( $thumbPath ) ) {
132139 wfStreamFile( $thumbPath, $headers );
 140+ wfProfileOut( __METHOD__ );
133141 return;
134142 }
135143 }
136144 } catch ( MWException $e ) {
137145 wfThumbError( 500, $e->getHTML() );
 146+ wfProfileOut( __METHOD__ );
138147 return;
139148 }
140149
Index: branches/wmf/1.17wmf1/languages/LanguageConverter.php
@@ -345,6 +345,7 @@
346346 if ( !$toVariant ) {
347347 $toVariant = $this->getPreferredVariant();
348348 if ( !$toVariant ) {
 349+ wfProfileOut( __METHOD__ );
349350 return $text;
350351 }
351352 }
Property changes on: branches/wmf/1.17wmf1/languages/LanguageConverter.php
___________________________________________________________________
Modified: svn:mergeinfo
352353 Merged /trunk/phase3/languages/LanguageConverter.php:r81729,81890-81894,81896-81898,81900

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81729Make SVGMetadataExtractor less noisy when it reads SVGs from Adobe Illustrator.tstarling12:25, 8 February 2011
r81890Add missing wfProfileOutplatonides15:47, 10 February 2011
r81891Close wfProfileIn()splatonides15:53, 10 February 2011
r81892More wfProfileOut()ingplatonides16:04, 10 February 2011
r81893Fix profilingnikerabbit16:08, 10 February 2011
r81894Adding more wfProfileOut()platonides16:11, 10 February 2011
r81896Yet more additions of wfProfileOut()platonides16:39, 10 February 2011
r81897Add profiling to DjVuImage::retrieveMetaDataplatonides16:40, 10 February 2011
r81898Add profiling to the whole ResourceLoader::makeModuleResponseplatonides16:44, 10 February 2011
r81900Fix the wrong merge of r81894 after r81893platonides16:47, 10 February 2011

Status & tagging log