From 852e80700a765bf5bed301eb19097d14aeb49626 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 23 Dec 2008 21:19:31 +0000 Subject: [PATCH] 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). --- includes/EditPage.php | 81 ++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 67934d7d1d..6287aaa8f0 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -380,9 +380,9 @@ class EditPage { } if ( wfReadOnly() && $this->save ) { - // Force preview - $this->save = false; - $this->preview = true; + // Force preview + $this->save = false; + $this->preview = true; } $wgOut->addScriptFile( 'edit.js' ); @@ -404,7 +404,7 @@ class EditPage { if ( $this->previewOnOpen() ) { $this->formtype = 'preview'; } else { - $this->extractMetaDataFromArticle() ; + $this->extractMetaDataFromArticle () ; $this->formtype = 'initial'; } } @@ -448,6 +448,7 @@ class EditPage { # and redundantly check for locked database, blocked IPs, etc. # that edit() already checked just in case someone tries to sneak # in the back door with a hand-edited submission URL. + if ( 'save' == $this->formtype ) { if ( !$this->attemptSave() ) { wfProfileOut( __METHOD__."-business-end" ); @@ -1107,7 +1108,8 @@ class EditPage { # Some hook probably called this function without checking # for is_null($wgTitle) first. Bail out right here so we don't # do lots of work just to discard it right after. - if (is_null($wgTitle)) return; + if (is_null($wgTitle)) + return; $fname = 'EditPage::showEditForm'; wfProfileIn( $fname ); @@ -1127,7 +1129,6 @@ class EditPage { $this->setHeaders(); - $uComp = $this->checkUnicodeCompliantBrowser(); # Enabled article-related sidebar, toplinks, etc. $wgOut->setArticleRelated( true ); @@ -1169,18 +1170,18 @@ class EditPage { $wgOut->addWikiText( $this->hookError ); } - if ( !$uComp ) { + if ( !$this->checkUnicodeCompliantBrowser() ) { $wgOut->addWikiMsg( 'nonunicodebrowser' ); } + if ( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) { + // Let sysop know that this will make private content public if saved - if ( isset( $this->mArticle->mRevision ) ) { - // Let sysop know that this will make private content public if saved if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) { $wgOut->addWikiMsg( 'rev-deleted-text-permission' ); } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { $wgOut->addWikiMsg( 'rev-deleted-text-view' ); } - // Give archived revision header + if ( !$this->mArticle->mRevision->isCurrent() ) { $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() ); $wgOut->addWikiMsg( 'editingold' ); @@ -1192,14 +1193,16 @@ class EditPage { $wgOut->wrapWikiMsg( "
\n$1\n
", array( 'readonlywarning', wfReadOnlyReason() ) ); } elseif ( $wgUser->isAnon() && $this->formtype != 'preview' ) { $wgOut->wrapWikiMsg( '
$1
', 'anoneditwarning' ); - } else if ( $this->isCssJsSubpage ) { - # Check the skin exists - if ( $this->isValidCssJsSubpage ) { - if ( $this->formtype !== 'preview' ) { - $wgOut->addWikiMsg( 'usercssjsyoucanpreview' ); + } else { + if ( $this->isCssJsSubpage ) { + # Check the skin exists + if ( $this->isValidCssJsSubpage ) { + if ( $this->formtype !== 'preview' ) { + $wgOut->addWikiMsg( 'usercssjsyoucanpreview' ); + } + } else { + $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); } - } else { - $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); } } @@ -1226,9 +1229,11 @@ class EditPage { # Is this page under cascading protection from some source pages? list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources(); $notice = "$1\n"; - # Explain, and list the titles responsible - foreach( $cascadeSources as $page ) { - $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; + if ( count($cascadeSources) > 0 ) { + # Explain, and list the titles responsible + foreach( $cascadeSources as $page ) { + $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; + } } $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) ); } @@ -1241,8 +1246,7 @@ class EditPage { } if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { $wgOut->addHTML( "
\n" ); - $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), - $wgLang->formatNum( $wgMaxArticleSize ) ); + $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ); $wgOut->addHTML( "
\n" ); } elseif ( $this->kblength > 29 ) { $wgOut->addHTML( "
\n" ); @@ -1251,13 +1255,15 @@ class EditPage { } $q = 'action='.$this->action; + #if ( "no" == $redirect ) { $q .= "&redirect=no"; } $action = $wgTitle->escapeLocalURL( $q ); $colonSep = wfMsg( 'colon-separator' ); $summary = wfMsg( 'summary' ) . $colonSep; $subject = wfMsg( 'subject' ) . $colonSep; - $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) ); + $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), + wfMsgExt('cancel', array('parseinline')) ); $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. htmlspecialchars( wfMsg( 'edithelp' ) ).' '. @@ -1273,19 +1279,17 @@ class EditPage { '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ); } - if ( $wgUser->getOption('showtoolbar') && !$this->isCssJsSubpage ) { + if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) { # prepare toolbar for edit buttons $toolbar = EditPage::getEditToolbar(); } else { $toolbar = ''; } - // Activate checkboxes if user wants them to be always active + // activate checkboxes if user wants them to be always active if ( !$this->preview && !$this->diff ) { # Sort out the "watch" checkbox - if( $wgRequest->getBool( 'watchthis' ) ) { - $this->watchthis = true; // May be overriden by request parameters - } else if ( $wgUser->getOption( 'watchdefault' ) ) { + if ( $wgUser->getOption( 'watchdefault' ) ) { # Watch all edits $this->watchthis = true; } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) { @@ -1295,8 +1299,13 @@ class EditPage { # Already watched $this->watchthis = true; } - if ( $wgUser->getOption( 'minordefault' ) ) - $this->minoredit = true; + + # May be overriden by request parameters + if( $wgRequest->getBool( 'watchthis' ) ) { + $this->watchthis = true; + } + + if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; } $wgOut->addHTML( $this->editFormPageTop ); @@ -1305,6 +1314,7 @@ class EditPage { $this->displayPreviewArea( $previewOutput, true ); } + $wgOut->addHTML( $this->editFormTextTop ); # if this is a comment, show a subject line at the top, which is also the edit summary. @@ -1323,9 +1333,9 @@ class EditPage { $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary ); $summaryhiddens .= Xml::hidden( 'wpAutoSummary', $autosumm ); if ( $this->section == 'new' ) { - global $wgParser; $commentsubject="\n{$summaryhiddens}
"; $editsummary = "
\n"; + global $wgParser; $formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) ); $subjectpreview = $summarytext && $this->preview ? "
".wfMsg('subject-preview').$colonSep.$sk->commentBlock( $formattedSummary, $this->mTitle, true )."
\n" : ''; $summarypreview = ''; @@ -1346,8 +1356,7 @@ class EditPage { $hiddencats = $this->mArticle->getHiddenCategories(); $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats ); - $metadata = ''; - global $wgUseMetadataEdit; + global $wgUseMetadataEdit ; if ( $wgUseMetadataEdit ) { $metadata = $this->mMetaData ; $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ; @@ -1360,6 +1369,7 @@ class EditPage { /* /ToDo */ $metadata = $top . "" ; } + else $metadata = "" ; $recreate = ''; if ( $this->wasDeletedSinceLastEdit() ) { @@ -1386,7 +1396,8 @@ class EditPage { $buttons = $this->getEditButtons( $tabindex ); $buttonshtml = implode( $buttons, "\n" ); - $safemodehtml = $uComp ? '' : Xml::hidden( 'safemode', '1' ); + $safemodehtml = $this->checkUnicodeCompliantBrowser() + ? '' : Xml::hidden( 'safemode', '1' ); $wgOut->addHTML( <<