Last modified: 2008-11-21 00:32:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 16388 - HTMLFileCache's $mFileCache is initialized too late
HTMLFileCache's $mFileCache is initialized too late
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2008-11-19 02:01 UTC by Lambert Lum
Modified: 2008-11-21 00:32 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

HTMLFileCache modified to initialize mFileCache in constructor. (3.79 KB, application/x-httpd-php)
2008-11-19 11:34 UTC, Lambert Lum
diff patch that will propery initialize $mFileCache in constructor (3.79 KB, patch)
2008-11-20 22:01 UTC, Lambert Lum

Description Lambert Lum 2008-11-19 02:01:21 UTC
In HTMLFileCache.php, the isFileCacheGood() function has a side effect wherein mFileCache member variable is initialized, isFileCachedGood() calls isFileCached() calls fileCacheName() initialize $mFileCache. This mFileCache should be initialized in the constructor, not just initialized to "", but to a relevant file path, e.g. "/var/tmp/file_cache/2/29/Help%3AChocolate.html".

Further compounding the awkwardness of mFileCache initialization, there is a possibility for a nasty program crash. In Article.php, there is a line of code that looks like this.

  ob_start( array(&$cache, 'saveToFileCache' ) );

The callback function saveToFileCache() will be called at program termination. If there is no $mFileCache initialized, then a $mFileCache will built on the fly. Unfortunately, at program termination, all global objects have their destructors called. Lack of global objects will make it impossible to call Title::getPrefixedDBkey() to determine namespace. Specifically $wgContLang will go out of scope. Without $wgContLang, it will be impossible to build $mFileCache, at least for those wiki pages that have namespace.
Comment 1 Lambert Lum 2008-11-19 11:34:19 UTC
Created attachment 5535 [details]
HTMLFileCache modified to initialize mFileCache in constructor.

This patch is my fix for the aforementioned bug. It is much better than the one line fix I mentioned previously.
Comment 2 Lambert Lum 2008-11-19 11:35:49 UTC
The fastest way to fix the problem is replacing a single line in the constructor.

  $this->mFileCache = '';

replaced with

  $this->mFileCache = $this->fileCacheName(); 

The attached patch is a much better fix though. It's a lot more clean.
Comment 3 Chad H. 2008-11-20 01:49:02 UTC
Could you possibly upload the file as a unified diff?
Comment 4 Lambert Lum 2008-11-20 22:01:17 UTC
Created attachment 5536 [details]
diff patch that will propery initialize $mFileCache in constructor
Comment 5 Aaron Schulz 2008-11-21 00:32:12 UTC
Fixed in r43790

Note You need to log in before you can comment on or make changes to this bug.