Commit graph

21 commits

Author SHA1 Message Date
Roan Kattouw
37d7dc5653 (bug 26399) Preload module info for all modules in startup module, to prevent lots of individual queries. Also improve preloadModuleInfo() to register the absence of message blobs for modules that do have messages (they were being missed because they were expected to have blobs for this reason) 2010-12-23 21:01:54 +00:00
Roan Kattouw
1d0dd870b8 Proper exception handling in ResourceLoader. Catch exceptions and output them in comments. Instead of just surrounding everything in a big try { } block, catch module-level exceptions where possible to allow error-free modules loaded in the same request to still be output normally. Modules that don't get output because of an exception are marked as missing in the client-side loader so other modules depending on them won't get loaded either. 2010-12-23 20:14:18 +00:00
Trevor Parscal
63ea295de5 Moved CSS flipping to occur inside a module - this resolves a bug which occurs when flipping happens AFTER CSSMin::remap embeds a data URI of an un-flipped image. 2010-12-16 19:31:48 +00:00
Roan Kattouw
ef315d737e Make load.php output a comment explaining what's going on when no modules were requested rather than outputting nothing. Max made me do this because he hates blank pages 2010-12-10 17:21:09 +00:00
Roan Kattouw
02f47c3027 (bug 26130) ob_start( 'ob_gzhandler' ) in LocalSettings.php broke gzip output from load.php . This is caused by http://bugs.php.net/bug.php?id=36514 (ob_clean() removes GZIP header). Also noticed that load.php is affected by http://bugs.php.net/bug.php?id=51579 (ob_gzhandler generates non-empty 304s, invalid HTTP, triggers a Firefox bug) as well and fixed that too while I was at it. 2010-12-10 17:06:00 +00:00
Roan Kattouw
8016383670 Fix r75994 per CR: don't pass an array as a JS string if MessageBlobStore::get() doesn't return a blob for a module 2010-12-02 18:45:21 +00:00
Roan Kattouw
94f888278b Strip If-Modified-Since header to a valid timestamp in ResourceLoader; some clients (notably IE) append things like ;length=123. This is valid according to the HTTP spec but rarely used (and ignored by us). The recent wfTimestamp() rewrite caused a fatal error in wfTimestamp() when such a timestamp was fed to it. r77401 fixed this by trimming the timestamp in wfTimestamp() itself, but for cleanliness we should do this in RL too. 2010-12-02 16:54:06 +00:00
Trevor Parscal
18495ef0e5 Added missing name setting when initializing modules from preloaded info. 2010-11-30 01:40:22 +00:00
Tim Starling
dac5084f6d * Made Resources.php return a pure-data array instead of an ugly mix of data and code. This allows the class code to be lazy-loaded with the autoloader, for a performance advantage especially on non-APC installs. And using the convention where if the class is omitted, ResourceLoaderFileModule is assumed, the registration code becomes shorter and simpler.
* Modified ResourceLoader to lazy-initialise module objects, for a further performance advantage.
* Deleted ResourceLoader::getModules(), provided getModuleNames() instead. Although the startup module needs this functionality, it's slow to generate, so to avoid misuse, it's better to provide a foolproof fast interface and let the startup module do the slow thing itself.
* Modified ResourceLoader::register() to optionally accept an info array instead of an object.
* Added $wgResourceModules, allowing extensions to efficiently define their own resource loader modules. The trouble with hooks is that they contain code, and code is slow. We've been through all this before with i18n. Hooks are useful as a performance tool only if you call them very rarely.
* Moved ResourceLoader settings to their own section in DefaultSettings.php
* Added options to ResourceLoaderFileModule equivalent to the $localBasePath and $remoteBasePath parameters, to allow it to be instantiated via the new array style. Also added remoteExtPath, which allows modules to be registered before $wgExtensionAssetsPath is known.
* Added OutputPage::getResourceLoader(), mostly for debugging.
* The time saving at the moment is about 5ms per request with no extensions, which is significant already with 6 load.php requests for a cold cache page view. This is a much more scalable interface; the relative saving will grow as more extensions are added which use this interface, especially for non-APC installs.

Although the interface is backwards compatible, extension updates will follow in a subsequent commit.
2010-11-19 10:41:06 +00:00
Tim Starling
ec2acb239b * In ResourceLoaderContext, lazy-load $this->direction and $this->language, to avoid loading the whole English localisation for load.php requests which never call getHash().
* Interpreted some Trevor-speak in the doc comment of ResourceLoader::preloadModuleInfo().
* Made setMsgBlobMtime() (called from preloadModuleInfo()) actually work, by making getMsgBlobMtime() use the cached blob times if they are available.
2010-11-19 06:52:38 +00:00
Tim Starling
04b2b29db7 Use wfGetCache( CACHE_ANYTHING ) instead of $wgMemc to store the result of ResourceLoader::filter(). Speeds up cold cache view of the main page on a non-APC default installation by a factor of 2.3 (measured using siege, no concurrency, URL list captured from Firefox, server = my laptop). 2010-11-19 01:40:00 +00:00
Roan Kattouw
00e7d8232b Followup r75825: per bug 25610 comment #3, check for debug mode in all other places too. 2010-11-05 20:36:13 +00:00
Trevor Parscal
c519873cdc Fixed Doxygen incompatible JSDoc style comments (bad Trevor!) as per some comments on r75036. 2010-11-05 18:33:50 +00:00
Tim Starling
82f274088a * Introduced Xml::encodeJsCall(), to replace the awkward repetitive code that was doing the same thing throughout the resource loader with varying degrees of security and correctness.
* Modified Xml::encodeJsVar() to allow it to pass through JS expressions without encoding, using a special object.
* In ResourceLoader::makeModuleResponse(), renamed $messages to $messagesBlob to make it clear that it's JSON-encoded, not an array.
* Fixed MessageBlobStore to store {} for an empty message array instead of [].
* In ResourceLoader::makeMessageSetScript(), fixed call to non-existent function mediaWiki.msg.set.
* For security, changed the calling convention of makeMessageSetScript() and makeLoaderImplementScript() to require explicit object construction of XmlJsCode() before interpreting their input as JS code.
* Documented several ResourceLoader static functions.
* In ResourceLoaderWikiModule, for readability, reduced the indenting level by flipping some if blocks and adding continue statements.
* In makeCustomLoaderScript(), allow non-numeric $version. The only caller I can find is already sending a non-numeric $version, presumably it was broken. Luckily there aren't any loader scripts in existence, I had to make one to test it.
* wfGetDb -> wfGetDB
* Added an extra line break in the startup module output, for readability.
* In ResourceLoaderStartUpModule::getModuleRegistrations(), fixed another assignment expression
2010-11-04 07:53:37 +00:00
Tim Starling
06b2b1bd66 Resource loader minor changes. Fix for r73668 etc.
* Break long lines.
* Convert long or unnecessary ternary operator usages to if/else.
* Fixed excessively clever assignment expressions.
* Rename $cache to $cacheEntry.
* Removed unnecessary web invocation guards. Their perlish form was making me uncomfortable. BTW, unlike in Perl, die() is not a function, it's a special case in the PHP grammar which very roughly simulates the Perl syntax:

die "x"; // works
0 || die("x"); // works
0 || (die); // works
0 || (die "x"); // fail!
2010-11-03 07:58:03 +00:00
Roan Kattouw
a6b765ffd1 (bug 25573) Send Cache-Control: must-revalidate in debug mode 2010-11-01 20:48:30 +00:00
Alexandre Emsenhuber
d835a78a25 * Fixed some doxygen warnings
* Made documentation cosistent with the rest of the software
2010-10-31 14:28:44 +00:00
Roan Kattouw
3517d951ba Some comment fixes: be consistent between # and //, fix grammar, remove information about internals from Doxygen comment (those are about what the function does, not how). Also make $modules argument to makeModuleResponse() default to array() instead of null 2010-10-20 14:58:35 +00:00
Trevor Parscal
0caccb3d28 Whitespace, comments and general cleanup. 2010-10-20 00:22:25 +00:00
Antoine Musso
9adfb4f0a9 documentation, a couple notes about code and some whitespaces adjustements to make code easier to read. 2010-10-19 20:45:02 +00:00
Trevor Parscal
ef6baa91de Moved ResourceLoader classes to their own folder, preparing to also split ResourceLoaderModule.php into multiple files (it's getting a bit long now) 2010-10-19 18:21:38 +00:00
Renamed from includes/ResourceLoader.php (Browse further)