From 27498bf17c8fbc5ddbacef9a010bdd14b8aba5ff Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 22 Dec 2008 09:07:53 +0000 Subject: [PATCH] Tweaks from profiling --- includes/EditPage.php | 81 +++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 6287aaa8f0..67934d7d1d 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,7 +448,6 @@ 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" ); @@ -1108,8 +1107,7 @@ 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 ); @@ -1129,6 +1127,7 @@ class EditPage { $this->setHeaders(); + $uComp = $this->checkUnicodeCompliantBrowser(); # Enabled article-related sidebar, toplinks, etc. $wgOut->setArticleRelated( true ); @@ -1170,18 +1169,18 @@ class EditPage { $wgOut->addWikiText( $this->hookError ); } - if ( !$this->checkUnicodeCompliantBrowser() ) { + if ( !$uComp ) { $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' ); @@ -1193,16 +1192,14 @@ 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 { - $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); + } else if ( $this->isCssJsSubpage ) { + # Check the skin exists + if ( $this->isValidCssJsSubpage ) { + if ( $this->formtype !== 'preview' ) { + $wgOut->addWikiMsg( 'usercssjsyoucanpreview' ); } + } else { + $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); } } @@ -1229,11 +1226,9 @@ class EditPage { # Is this page under cascading protection from some source pages? list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources(); $notice = "$1\n"; - if ( count($cascadeSources) > 0 ) { - # Explain, and list the titles responsible - foreach( $cascadeSources as $page ) { - $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; - } + # Explain, and list the titles responsible + foreach( $cascadeSources as $page ) { + $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; } $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) ); } @@ -1246,7 +1241,8 @@ 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" ); @@ -1255,15 +1251,13 @@ 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' ) ).' '. @@ -1279,17 +1273,19 @@ class EditPage { '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ); } - if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) { + if ( $wgUser->getOption('showtoolbar') && !$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 ( $wgUser->getOption( 'watchdefault' ) ) { + if( $wgRequest->getBool( 'watchthis' ) ) { + $this->watchthis = true; // May be overriden by request parameters + } else if ( $wgUser->getOption( 'watchdefault' ) ) { # Watch all edits $this->watchthis = true; } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) { @@ -1299,13 +1295,8 @@ class EditPage { # Already watched $this->watchthis = true; } - - # May be overriden by request parameters - if( $wgRequest->getBool( 'watchthis' ) ) { - $this->watchthis = true; - } - - if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; + if ( $wgUser->getOption( 'minordefault' ) ) + $this->minoredit = true; } $wgOut->addHTML( $this->editFormPageTop ); @@ -1314,7 +1305,6 @@ 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. @@ -1333,9 +1323,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 = ''; @@ -1356,7 +1346,8 @@ class EditPage { $hiddencats = $this->mArticle->getHiddenCategories(); $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats ); - global $wgUseMetadataEdit ; + $metadata = ''; + global $wgUseMetadataEdit; if ( $wgUseMetadataEdit ) { $metadata = $this->mMetaData ; $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ; @@ -1369,7 +1360,6 @@ class EditPage { /* /ToDo */ $metadata = $top . "" ; } - else $metadata = "" ; $recreate = ''; if ( $this->wasDeletedSinceLastEdit() ) { @@ -1396,8 +1386,7 @@ class EditPage { $buttons = $this->getEditButtons( $tabindex ); $buttonshtml = implode( $buttons, "\n" ); - $safemodehtml = $this->checkUnicodeCompliantBrowser() - ? '' : Xml::hidden( 'safemode', '1' ); + $safemodehtml = $uComp ? '' : Xml::hidden( 'safemode', '1' ); $wgOut->addHTML( <<