r44893 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44892‎ | r44893 | r44894 >
Date:09:07, 22 December 2008
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Tweaks from profiling
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,7 +448,6 @@
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 -
453452 if ( 'save' == $this->formtype ) {
454453 if ( !$this->attemptSave() ) {
455454 wfProfileOut( __METHOD__."-business-end" );
@@ -1108,8 +1107,7 @@
11091108 # Some hook probably called this function without checking
11101109 # for is_null($wgTitle) first. Bail out right here so we don't
11111110 # do lots of work just to discard it right after.
1112 - if (is_null($wgTitle))
1113 - return;
 1111+ if (is_null($wgTitle)) return;
11141112
11151113 $fname = 'EditPage::showEditForm';
11161114 wfProfileIn( $fname );
@@ -1129,6 +1127,7 @@
11301128
11311129 $this->setHeaders();
11321130
 1131+ $uComp = $this->checkUnicodeCompliantBrowser();
11331132 # Enabled article-related sidebar, toplinks, etc.
11341133 $wgOut->setArticleRelated( true );
11351134
@@ -1170,18 +1169,18 @@
11711170 $wgOut->addWikiText( $this->hookError );
11721171 }
11731172
1174 - if ( !$this->checkUnicodeCompliantBrowser() ) {
 1173+ if ( !$uComp ) {
11751174 $wgOut->addWikiMsg( 'nonunicodebrowser' );
11761175 }
1177 - if ( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) {
1178 - // Let sysop know that this will make private content public if saved
11791176
 1177+ if ( isset( $this->mArticle->mRevision ) ) {
 1178+ // Let sysop know that this will make private content public if saved
11801179 if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
11811180 $wgOut->addWikiMsg( 'rev-deleted-text-permission' );
11821181 } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
11831182 $wgOut->addWikiMsg( 'rev-deleted-text-view' );
11841183 }
1185 -
 1184+ // Give archived revision header
11861185 if ( !$this->mArticle->mRevision->isCurrent() ) {
11871186 $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() );
11881187 $wgOut->addWikiMsg( 'editingold' );
@@ -1193,16 +1192,14 @@
11941193 $wgOut->wrapWikiMsg( "<div id=\"mw-read-only-warning\">\n$1\n</div>", array( 'readonlywarning', wfReadOnlyReason() ) );
11951194 } elseif ( $wgUser->isAnon() && $this->formtype != 'preview' ) {
11961195 $wgOut->wrapWikiMsg( '<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning' );
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() );
 1196+ } else if ( $this->isCssJsSubpage ) {
 1197+ # Check the skin exists
 1198+ if ( $this->isValidCssJsSubpage ) {
 1199+ if ( $this->formtype !== 'preview' ) {
 1200+ $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
12061201 }
 1202+ } else {
 1203+ $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
12071204 }
12081205 }
12091206
@@ -1229,11 +1226,9 @@
12301227 # Is this page under cascading protection from some source pages?
12311228 list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources();
12321229 $notice = "$1\n";
1233 - if ( count($cascadeSources) > 0 ) {
1234 - # Explain, and list the titles responsible
1235 - foreach( $cascadeSources as $page ) {
1236 - $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
1237 - }
 1230+ # Explain, and list the titles responsible
 1231+ foreach( $cascadeSources as $page ) {
 1232+ $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
12381233 }
12391234 $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) );
12401235 }
@@ -1246,7 +1241,8 @@
12471242 }
12481243 if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
12491244 $wgOut->addHTML( "<div class='error' id='mw-edit-longpageerror'>\n" );
1250 - $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) );
 1245+ $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ),
 1246+ $wgLang->formatNum( $wgMaxArticleSize ) );
12511247 $wgOut->addHTML( "</div>\n" );
12521248 } elseif ( $this->kblength > 29 ) {
12531249 $wgOut->addHTML( "<div id='mw-edit-longpagewarning'>\n" );
@@ -1255,15 +1251,13 @@
12561252 }
12571253
12581254 $q = 'action='.$this->action;
1259 - #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
12601255 $action = $wgTitle->escapeLocalURL( $q );
12611256
12621257 $colonSep = wfMsg( 'colon-separator' );
12631258 $summary = wfMsg( 'summary' ) . $colonSep;
12641259 $subject = wfMsg( 'subject' ) . $colonSep;
12651260
1266 - $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(),
1267 - wfMsgExt('cancel', array('parseinline')) );
 1261+ $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) );
12681262 $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ));
12691263 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
12701264 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
@@ -1279,17 +1273,19 @@
12801274 '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' );
12811275 }
12821276
1283 - if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) {
 1277+ if ( $wgUser->getOption('showtoolbar') && !$this->isCssJsSubpage ) {
12841278 # prepare toolbar for edit buttons
12851279 $toolbar = EditPage::getEditToolbar();
12861280 } else {
12871281 $toolbar = '';
12881282 }
12891283
1290 - // activate checkboxes if user wants them to be always active
 1284+ // Activate checkboxes if user wants them to be always active
12911285 if ( !$this->preview && !$this->diff ) {
12921286 # Sort out the "watch" checkbox
1293 - if ( $wgUser->getOption( 'watchdefault' ) ) {
 1287+ if( $wgRequest->getBool( 'watchthis' ) ) {
 1288+ $this->watchthis = true; // May be overriden by request parameters
 1289+ } else if ( $wgUser->getOption( 'watchdefault' ) ) {
12941290 # Watch all edits
12951291 $this->watchthis = true;
12961292 } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) {
@@ -1299,13 +1295,8 @@
13001296 # Already watched
13011297 $this->watchthis = true;
13021298 }
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;
 1299+ if ( $wgUser->getOption( 'minordefault' ) )
 1300+ $this->minoredit = true;
13101301 }
13111302
13121303 $wgOut->addHTML( $this->editFormPageTop );
@@ -1314,7 +1305,6 @@
13151306 $this->displayPreviewArea( $previewOutput, true );
13161307 }
13171308
1318 -
13191309 $wgOut->addHTML( $this->editFormTextTop );
13201310
13211311 # if this is a comment, show a subject line at the top, which is also the edit summary.
@@ -1333,9 +1323,9 @@
13341324 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
13351325 $summaryhiddens .= Xml::hidden( 'wpAutoSummary', $autosumm );
13361326 if ( $this->section == 'new' ) {
 1327+ global $wgParser;
13371328 $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 />";
13381329 $editsummary = "<div class='editOptions'>\n";
1339 - global $wgParser;
13401330 $formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) );
13411331 $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">".wfMsg('subject-preview').$colonSep.$sk->commentBlock( $formattedSummary, $this->mTitle, true )."</div>\n" : '';
13421332 $summarypreview = '';
@@ -1356,7 +1346,8 @@
13571347 $hiddencats = $this->mArticle->getHiddenCategories();
13581348 $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats );
13591349
1360 - global $wgUseMetadataEdit ;
 1350+ $metadata = '';
 1351+ global $wgUseMetadataEdit;
13611352 if ( $wgUseMetadataEdit ) {
13621353 $metadata = $this->mMetaData ;
13631354 $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ;
@@ -1369,7 +1360,6 @@
13701361 /* /ToDo */
13711362 $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>" ;
13721363 }
1373 - else $metadata = "" ;
13741364
13751365 $recreate = '';
13761366 if ( $this->wasDeletedSinceLastEdit() ) {
@@ -1396,8 +1386,7 @@
13971387 $buttons = $this->getEditButtons( $tabindex );
13981388 $buttonshtml = implode( $buttons, "\n" );
13991389
1400 - $safemodehtml = $this->checkUnicodeCompliantBrowser()
1401 - ? '' : Xml::hidden( 'safemode', '1' );
 1390+ $safemodehtml = $uComp ? '' : Xml::hidden( 'safemode', '1' );
14021391
14031392 $wgOut->addHTML( <<<END
14041393 {$toolbar}
@@ -1405,7 +1394,7 @@
14061395 END
14071396 );
14081397
1409 - if ( is_callable( $formCallback ) ) {
 1398+ if ( $formCallback && is_callable( $formCallback ) ) {
14101399 call_user_func_array( $formCallback, array( &$wgOut ) );
14111400 }
14121401

Follow-up revisions

RevisionCommit summaryAuthorDate
r44975Revert r44893 "Tweaks from profiling"...brion21:19, 23 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   21:19, 23 December 2008

Reverted in r44975.

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).

Status & tagging log