r44975 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44974‎ | r44975 | r44976 >
Date:21:19, 23 December 2008
Author:brion
Status:ok
Tags:
Comment:
Revert r44893 "Tweaks from profiling"
It's unclear what, if anything, has any serious performance effect here.
Seems to be trivial code formatting changes, some of which are nice (breaking long lines), others which aren't (creating long lines from nicely broken ones).
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -380,9 +380,9 @@
381381 }
382382
383383 if ( wfReadOnly() && $this->save ) {
384 - // Force preview
385 - $this->save = false;
386 - $this->preview = true;
 384+ // Force preview
 385+ $this->save = false;
 386+ $this->preview = true;
387387 }
388388
389389 $wgOut->addScriptFile( 'edit.js' );
@@ -404,7 +404,7 @@
405405 if ( $this->previewOnOpen() ) {
406406 $this->formtype = 'preview';
407407 } else {
408 - $this->extractMetaDataFromArticle() ;
 408+ $this->extractMetaDataFromArticle () ;
409409 $this->formtype = 'initial';
410410 }
411411 }
@@ -448,6 +448,7 @@
449449 # and redundantly check for locked database, blocked IPs, etc.
450450 # that edit() already checked just in case someone tries to sneak
451451 # in the back door with a hand-edited submission URL.
 452+
452453 if ( 'save' == $this->formtype ) {
453454 if ( !$this->attemptSave() ) {
454455 wfProfileOut( __METHOD__."-business-end" );
@@ -1107,7 +1108,8 @@
11081109 # Some hook probably called this function without checking
11091110 # for is_null($wgTitle) first. Bail out right here so we don't
11101111 # do lots of work just to discard it right after.
1111 - if (is_null($wgTitle)) return;
 1112+ if (is_null($wgTitle))
 1113+ return;
11121114
11131115 $fname = 'EditPage::showEditForm';
11141116 wfProfileIn( $fname );
@@ -1127,7 +1129,6 @@
11281130
11291131 $this->setHeaders();
11301132
1131 - $uComp = $this->checkUnicodeCompliantBrowser();
11321133 # Enabled article-related sidebar, toplinks, etc.
11331134 $wgOut->setArticleRelated( true );
11341135
@@ -1169,18 +1170,18 @@
11701171 $wgOut->addWikiText( $this->hookError );
11711172 }
11721173
1173 - if ( !$uComp ) {
 1174+ if ( !$this->checkUnicodeCompliantBrowser() ) {
11741175 $wgOut->addWikiMsg( 'nonunicodebrowser' );
11751176 }
 1177+ if ( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) {
 1178+ // Let sysop know that this will make private content public if saved
11761179
1177 - if ( isset( $this->mArticle->mRevision ) ) {
1178 - // Let sysop know that this will make private content public if saved
11791180 if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
11801181 $wgOut->addWikiMsg( 'rev-deleted-text-permission' );
11811182 } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
11821183 $wgOut->addWikiMsg( 'rev-deleted-text-view' );
11831184 }
1184 - // Give archived revision header
 1185+
11851186 if ( !$this->mArticle->mRevision->isCurrent() ) {
11861187 $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() );
11871188 $wgOut->addWikiMsg( 'editingold' );
@@ -1192,14 +1193,16 @@
11931194 $wgOut->wrapWikiMsg( "<div id=\"mw-read-only-warning\">\n$1\n</div>", array( 'readonlywarning', wfReadOnlyReason() ) );
11941195 } elseif ( $wgUser->isAnon() && $this->formtype != 'preview' ) {
11951196 $wgOut->wrapWikiMsg( '<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning' );
1196 - } else if ( $this->isCssJsSubpage ) {
1197 - # Check the skin exists
1198 - if ( $this->isValidCssJsSubpage ) {
1199 - if ( $this->formtype !== 'preview' ) {
1200 - $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
 1197+ } else {
 1198+ if ( $this->isCssJsSubpage ) {
 1199+ # Check the skin exists
 1200+ if ( $this->isValidCssJsSubpage ) {
 1201+ if ( $this->formtype !== 'preview' ) {
 1202+ $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
 1203+ }
 1204+ } else {
 1205+ $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
12011206 }
1202 - } else {
1203 - $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
12041207 }
12051208 }
12061209
@@ -1226,9 +1229,11 @@
12271230 # Is this page under cascading protection from some source pages?
12281231 list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources();
12291232 $notice = "$1\n";
1230 - # Explain, and list the titles responsible
1231 - foreach( $cascadeSources as $page ) {
1232 - $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
 1233+ if ( count($cascadeSources) > 0 ) {
 1234+ # Explain, and list the titles responsible
 1235+ foreach( $cascadeSources as $page ) {
 1236+ $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
 1237+ }
12331238 }
12341239 $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) );
12351240 }
@@ -1241,8 +1246,7 @@
12421247 }
12431248 if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
12441249 $wgOut->addHTML( "<div class='error' id='mw-edit-longpageerror'>\n" );
1245 - $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ),
1246 - $wgLang->formatNum( $wgMaxArticleSize ) );
 1250+ $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) );
12471251 $wgOut->addHTML( "</div>\n" );
12481252 } elseif ( $this->kblength > 29 ) {
12491253 $wgOut->addHTML( "<div id='mw-edit-longpagewarning'>\n" );
@@ -1251,13 +1255,15 @@
12521256 }
12531257
12541258 $q = 'action='.$this->action;
 1259+ #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
12551260 $action = $wgTitle->escapeLocalURL( $q );
12561261
12571262 $colonSep = wfMsg( 'colon-separator' );
12581263 $summary = wfMsg( 'summary' ) . $colonSep;
12591264 $subject = wfMsg( 'subject' ) . $colonSep;
12601265
1261 - $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) );
 1266+ $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(),
 1267+ wfMsgExt('cancel', array('parseinline')) );
12621268 $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ));
12631269 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
12641270 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
@@ -1273,19 +1279,17 @@
12741280 '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' );
12751281 }
12761282
1277 - if ( $wgUser->getOption('showtoolbar') && !$this->isCssJsSubpage ) {
 1283+ if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) {
12781284 # prepare toolbar for edit buttons
12791285 $toolbar = EditPage::getEditToolbar();
12801286 } else {
12811287 $toolbar = '';
12821288 }
12831289
1284 - // Activate checkboxes if user wants them to be always active
 1290+ // activate checkboxes if user wants them to be always active
12851291 if ( !$this->preview && !$this->diff ) {
12861292 # Sort out the "watch" checkbox
1287 - if( $wgRequest->getBool( 'watchthis' ) ) {
1288 - $this->watchthis = true; // May be overriden by request parameters
1289 - } else if ( $wgUser->getOption( 'watchdefault' ) ) {
 1293+ if ( $wgUser->getOption( 'watchdefault' ) ) {
12901294 # Watch all edits
12911295 $this->watchthis = true;
12921296 } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) {
@@ -1295,8 +1299,13 @@
12961300 # Already watched
12971301 $this->watchthis = true;
12981302 }
1299 - if ( $wgUser->getOption( 'minordefault' ) )
1300 - $this->minoredit = true;
 1303+
 1304+ # May be overriden by request parameters
 1305+ if( $wgRequest->getBool( 'watchthis' ) ) {
 1306+ $this->watchthis = true;
 1307+ }
 1308+
 1309+ if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
13011310 }
13021311
13031312 $wgOut->addHTML( $this->editFormPageTop );
@@ -1305,6 +1314,7 @@
13061315 $this->displayPreviewArea( $previewOutput, true );
13071316 }
13081317
 1318+
13091319 $wgOut->addHTML( $this->editFormTextTop );
13101320
13111321 # if this is a comment, show a subject line at the top, which is also the edit summary.
@@ -1323,9 +1333,9 @@
13241334 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
13251335 $summaryhiddens .= Xml::hidden( 'wpAutoSummary', $autosumm );
13261336 if ( $this->section == 'new' ) {
1327 - global $wgParser;
13281337 $commentsubject="<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}</label></span>\n<input tabindex='1' type='text' value=\"$summarytext\" name='wpSummary' id='wpSummary' maxlength='200' size='60' />{$summaryhiddens}<br />";
13291338 $editsummary = "<div class='editOptions'>\n";
 1339+ global $wgParser;
13301340 $formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) );
13311341 $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">".wfMsg('subject-preview').$colonSep.$sk->commentBlock( $formattedSummary, $this->mTitle, true )."</div>\n" : '';
13321342 $summarypreview = '';
@@ -1346,8 +1356,7 @@
13471357 $hiddencats = $this->mArticle->getHiddenCategories();
13481358 $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats );
13491359
1350 - $metadata = '';
1351 - global $wgUseMetadataEdit;
 1360+ global $wgUseMetadataEdit ;
13521361 if ( $wgUseMetadataEdit ) {
13531362 $metadata = $this->mMetaData ;
13541363 $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ;
@@ -1360,6 +1369,7 @@
13611370 /* /ToDo */
13621371 $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>" ;
13631372 }
 1373+ else $metadata = "" ;
13641374
13651375 $recreate = '';
13661376 if ( $this->wasDeletedSinceLastEdit() ) {
@@ -1386,7 +1396,8 @@
13871397 $buttons = $this->getEditButtons( $tabindex );
13881398 $buttonshtml = implode( $buttons, "\n" );
13891399
1390 - $safemodehtml = $uComp ? '' : Xml::hidden( 'safemode', '1' );
 1400+ $safemodehtml = $this->checkUnicodeCompliantBrowser()
 1401+ ? '' : Xml::hidden( 'safemode', '1' );
13911402
13921403 $wgOut->addHTML( <<<END
13931404 {$toolbar}
@@ -1394,7 +1405,7 @@
13951406 END
13961407 );
13971408
1398 - if ( $formCallback && is_callable( $formCallback ) ) {
 1409+ if ( is_callable( $formCallback ) ) {
13991410 call_user_func_array( $formCallback, array( &$wgOut ) );
14001411 }
14011412

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44893Tweaks from profilingaaron09:07, 22 December 2008

Status & tagging log