r44986 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44985‎ | r44986 | r44987 >
Date:22:48, 23 December 2008
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Skip redirect checks for NS_MEDIAWIKI
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -42,6 +42,7 @@
4343 /**
4444 * Initialization of ... everything
4545 * Performs the request too
 46+ * FIXME: why is this crap called "initialize" when it performs everything?
4647 *
4748 * @param $title Title ($wgTitle)
4849 * @param $article Article
@@ -85,7 +86,6 @@
8687 }
8788 }
8889
89 -
9090 /**
9191 * Checks some initial queries
9292 * Note that $title here is *not* a Title object, but a string!
@@ -157,6 +157,8 @@
158158 * - redirect loop
159159 * - special pages
160160 *
 161+ * FIXME: why is this crap called "initialize" when it performs everything?
 162+ *
161163 * @param $title Title
162164 * @param $output OutputPage
163165 * @param $request WebRequest
@@ -286,9 +288,14 @@
287289 function initializeArticle( &$title, $request ) {
288290 wfProfileIn( __METHOD__ );
289291
290 - $action = $this->getVal( 'action' );
 292+ $action = $this->getVal( 'action', 'view' );
291293 $article = self::articleFromTitle( $title );
292 -
 294+ # NS_MEDIAWIKI has no redirects.
 295+ # It is also used for CSS/JS, so performance matters here...
 296+ if( $title->getNamespace() == NS_MEDIAWIKI ) {
 297+ wfProfileOut( __METHOD__ );
 298+ return $article;
 299+ }
293300 // Namespace might change when using redirects
294301 // Check for redirects ...
295302 $file = ($title->getNamespace() == NS_FILE) ? $article->getFile() : null;
@@ -317,8 +324,7 @@
318325 return $target;
319326 }
320327 }
321 -
322 - if( is_object( $target ) ) {
 328+ if( is_object($target) ) {
323329 // Rewrite environment to redirected article
324330 $rarticle = self::articleFromTitle( $target );
325331 $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );

Comments

#Comment by Simetrical (talk | contribs)   22:53, 23 December 2008

"It is also used for CSS/JS, so performance matters here..."

No. No, it really doesn't. (Unless profiling shows it really does, in which case I take it back.) CSS/JS are going to be among the most heavily cached objects served. Why are you doing all of this random stuff under the guise of optimization instead of consulting the actual figures on what's using the most CPU time? In terms of user experience, network delay is hundreds of milliseconds: shaving off tens or hundreds of microseconds per request is not noticeable. You're possibly creating bugs and almost certainly not doing anything useful.

To quote Donald Knuth, "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."

#Comment by Aaron Schulz (talk | contribs)   22:56, 23 December 2008

I killing db queries and waste on normal installs with just filecache. Obviously WMF has squids that cache this stuff, so it won't affect theme. profileinfo.php what I am using as "actual figures", not just the "guise" of something.

#Comment by Simetrical (talk | contribs)   23:05, 23 December 2008

Then you should cite the performance figures in your commit message and explain this. Nobody can legitimately evaluate your commits if you don't give us the reasoning behind them, especially if the reasoning involves hard numbers we don't have access to. Your commit messages usually don't explain things well at all, I often have no idea what you're doing when looking at your commits.

As for this particular commit, redirects currently don't work in the MediaWiki namespace, but I don't know if we want to litter assumptions that that will remain true forever throughout the codebase.

#Comment by Aaron Schulz (talk | contribs)   22:57, 23 December 2008

sigh... s/theme/them, s/what/is what

#Comment by Simetrical (talk | contribs)   23:10, 23 December 2008

Also, the stray change of is_object( $target ) to is_object($target) violates our coding style . . .

Status & tagging log