r108610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108609‎ | r108610 | r108611 >
Date:10:33, 11 January 2012
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Moved RessourceLoader modules and stylesheet related stuff from EditPage::edit() to EditPage::setHeaders() and header messages to EditPage::showHeader(); there's no point running all that code when the edit form is not displayed (e.g. page save).
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -234,14 +234,6 @@
235235 return;
236236 }
237237
238 - $wgOut->addModules( 'mediawiki.action.edit' );
239 -
240 - if ( $wgUser->getOption( 'uselivepreview', false ) ) {
241 - $wgOut->addModules( 'mediawiki.legacy.preview' );
242 - }
243 - // Bug #19334: textarea jumps when editing articles in IE8
244 - $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
245 -
246238 wfProfileIn( __METHOD__."-business-end" );
247239
248240 $this->isConflict = false;
@@ -253,38 +245,10 @@
254246 $this->isNew = !$this->mTitle->exists() || $this->section == 'new';
255247
256248 # Show applicable editing introductions
257 - if ( $this->formtype == 'initial' || $this->firsttime )
 249+ if ( $this->formtype == 'initial' || $this->firsttime ) {
258250 $this->showIntro();
259 -
260 - if ( $this->mTitle->isTalkPage() ) {
261 - $wgOut->addWikiMsg( 'talkpagetext' );
262251 }
263252
264 - # Optional notices on a per-namespace and per-page basis
265 - $editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace();
266 - $editnotice_ns_message = wfMessage( $editnotice_ns )->inContentLanguage();
267 - if ( $editnotice_ns_message->exists() ) {
268 - $wgOut->addWikiText( $editnotice_ns_message->plain() );
269 - }
270 - if ( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
271 - $parts = explode( '/', $this->mTitle->getDBkey() );
272 - $editnotice_base = $editnotice_ns;
273 - while ( count( $parts ) > 0 ) {
274 - $editnotice_base .= '-'.array_shift( $parts );
275 - $editnotice_base_msg = wfMessage( $editnotice_base )->inContentLanguage();
276 - if ( $editnotice_base_msg->exists() ) {
277 - $wgOut->addWikiText( $editnotice_base_msg->plain() );
278 - }
279 - }
280 - } else {
281 - # Even if there are no subpages in namespace, we still don't want / in MW ns.
282 - $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->mTitle->getDBkey() );
283 - $editnoticeMsg = wfMessage( $editnoticeText )->inContentLanguage();
284 - if ( $editnoticeMsg->exists() ) {
285 - $wgOut->addWikiText( $editnoticeMsg->plain() );
286 - }
287 - }
288 -
289253 # Attempt submission here. This will check for edit conflicts,
290254 # and redundantly check for locked database, blocked IPs, etc.
291255 # that edit() already checked just in case someone tries to sneak
@@ -1526,8 +1490,21 @@
15271491 }
15281492
15291493 function setHeaders() {
1530 - global $wgOut;
 1494+ global $wgOut, $wgUser;
 1495+
 1496+ $wgOut->addModules( 'mediawiki.action.edit' );
 1497+
 1498+ if ( $wgUser->getOption( 'uselivepreview', false ) ) {
 1499+ $wgOut->addModules( 'mediawiki.legacy.preview' );
 1500+ }
 1501+ // Bug #19334: textarea jumps when editing articles in IE8
 1502+ $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
 1503+
15311504 $wgOut->setRobotPolicy( 'noindex,nofollow' );
 1505+
 1506+ # Enabled article-related sidebar, toplinks, etc.
 1507+ $wgOut->setArticleRelated( true );
 1508+
15321509 if ( $this->isConflict ) {
15331510 $wgOut->setPageTitle( wfMessage( 'editconflict', $this->getContextTitle()->getPrefixedText() ) );
15341511 } elseif ( $this->section != '' ) {
@@ -1651,9 +1628,6 @@
16521629
16531630 $this->setHeaders();
16541631
1655 - # Enabled article-related sidebar, toplinks, etc.
1656 - $wgOut->setArticleRelated( true );
1657 -
16581632 if ( $this->showHeader() === false ) {
16591633 wfProfileOut( __METHOD__ );
16601634 return;
@@ -1804,6 +1778,36 @@
18051779
18061780 protected function showHeader() {
18071781 global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
 1782+
 1783+ if ( $this->mTitle->isTalkPage() ) {
 1784+ $wgOut->addWikiMsg( 'talkpagetext' );
 1785+ }
 1786+
 1787+ # Optional notices on a per-namespace and per-page basis
 1788+ $editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace();
 1789+ $editnotice_ns_message = wfMessage( $editnotice_ns )->inContentLanguage();
 1790+ if ( $editnotice_ns_message->exists() ) {
 1791+ $wgOut->addWikiText( $editnotice_ns_message->plain() );
 1792+ }
 1793+ if ( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
 1794+ $parts = explode( '/', $this->mTitle->getDBkey() );
 1795+ $editnotice_base = $editnotice_ns;
 1796+ while ( count( $parts ) > 0 ) {
 1797+ $editnotice_base .= '-'.array_shift( $parts );
 1798+ $editnotice_base_msg = wfMessage( $editnotice_base )->inContentLanguage();
 1799+ if ( $editnotice_base_msg->exists() ) {
 1800+ $wgOut->addWikiText( $editnotice_base_msg->plain() );
 1801+ }
 1802+ }
 1803+ } else {
 1804+ # Even if there are no subpages in namespace, we still don't want / in MW ns.
 1805+ $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->mTitle->getDBkey() );
 1806+ $editnoticeMsg = wfMessage( $editnoticeText )->inContentLanguage();
 1807+ if ( $editnoticeMsg->exists() ) {
 1808+ $wgOut->addWikiText( $editnoticeMsg->plain() );
 1809+ }
 1810+ }
 1811+
18081812 if ( $this->isConflict ) {
18091813 $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
18101814 $this->edittime = $this->mArticle->getTimestamp();

Sign-offs

UserFlagDate
Nikerabbitinspected13:44, 11 January 2012

Comments

#Comment by Aaron Schulz (talk | contribs)   00:14, 13 January 2012

Would be nice if showHeader() always returned a value (rather than implicit null). This was pre-existing of course.

Status & tagging log