Commit graph

71 commits

Author SHA1 Message Date
Aaron Schulz
5dc9336cf4 FU r98698: Show any PHP warnings in tryRespondFromFileCache() in debug mode 2011-12-17 05:02:15 +00:00
Brion Vibber
e97346ec18 Revert r103978, r103979 -- screwed something up, breaks jQuery minification.
Incremented ResourceLoader::filterCacheVersion rather than decrementing to avoid potential confusion, especially since we already needed the incr.
2011-11-23 00:22:46 +00:00
Brion Vibber
956de0db3f Functional part of r103978 (d'oh!) plus an update to the ResourceLoader filter cache key, so broken entries stuck in cache will be reloaded. 2011-11-22 23:20:50 +00:00
Roan Kattouw
f12177ce20 Make ResourceLoader::register() non-recursive, was calling itself recursively on every page load. 2011-11-19 16:02:26 +00:00
Platonides
d71e657d59 The early return added in r98698 was skipping the closing wfProfileOut(). 2011-10-27 20:50:07 +00:00
Sam Reed
f8a0e34ca1 Documentation
Trim trailing whitespace

Make returns return values where appropriate (ie other paths in the same method do)
2011-10-14 08:06:54 +00:00
Aaron Schulz
93d358cd0c FileCache:
* Added FileCacheBase::*MissesRecent() functions for counting cache misses from different visitors.
* Made ObjectFileCache more generic.
* Cleaned up FileCacheBase::checkCacheDirs().
* Added FileCacheBase::typeSubdirectory() function and overwrote in HTMLFileCache. Fixes r98405 invalidating all existing cache due to directory change.
* Simplified FileCacheBase::checkCacheDirs() a bit

ResourceLoader:
* Use ResourceFileCache to handle load() requests, if $wgUseFileCache. Only caches requests for default language and skins. Single modules requests are always cached, whereas others require a certain threshold of traffic.
* Added ResourceFileCache class (functionality was initially to be in ObjectFileCache).
2011-10-02 17:53:33 +00:00
Aaron Schulz
a7bd3bed3c Reverted stuff from r98602 committed by mistake 2011-10-01 05:03:10 +00:00
Aaron Schulz
9ac53dcc3b Made provideIPCIDRs() not add a '/' if there is no prefix length. Fixes bug 31234. 2011-10-01 04:54:44 +00:00
Aaron Schulz
9b2cff1c2d Refactored out new sendResponseHeaders() and tryRespondLastModified() functions out of respond() code. These changes were made for $wgUseFileCache support (haven't committed the other stuff here). 2011-10-01 04:15:07 +00:00
Roan Kattouw
2b05b95a6d Address fixme on r96978: expand URLs fed to the client-side loader 2011-09-30 10:14:39 +00:00
Krinkle
32327650c5 clean up Html::inlineScript usage
* ResourceLoader::makeLoaderConditionalScript:
-- window.mediaWiki -> window.mw; Not just because it's shorter but because that's the variable that is actually being used inside the script.
* ProtectionForm::buildCleanupScript
-- Use a single quote string and no new line
-- Use ResourceLoader::makeLoaderConditionalScript instead of duplicating this logic everywhere
* ProtectionForm::buildCleanupScript:
-- Use Xml::encodeJsCall to render javascript code
-- Use ResourceLoader::makeLoaderConditionalScript
-- Fix bug 31230 by using the new OutputPage->addJsConfigVars( r98374 )
(had to use $wgOut for now since there wasn't an obvious route to a context that I could find here (Article has context, but ProtectionForm::__construct takes any WikiPage, not just Article)
* EditPage::getEditToolbar:
-- Use Xml::encodeJsCall
-- Use ResourceLoader::makeLoaderConditionalScript

Fixes:
* (bug 31230) ProtectionForm should set wgCascadeableLevels in mw.confg instead of globally
2011-09-28 22:47:05 +00:00
Niklas Laxström
c94639fe2d rv r97851 for further inspection, causes PHP notices 2011-09-22 21:27:04 +00:00
Ilmari Karonen
b0f51413b0 followup r79862: the for loop only cleans up half the output handlers (since $i counts up while ob_get_level() counts down); check the return value of ob_end_clean() instead.
(I just noticed this while eyeballing the code -- apparently most people don't have multiple output handlers active, given that nobody had caught this in over eight months.)
2011-09-22 20:44:05 +00:00
Roan Kattouw
b9af8a8118 Followup r93247: add apiScript as a property of a ResourceLoader source. 2011-09-15 15:40:40 +00:00
Roan Kattouw
488d368b86 Followup r96978, clean up code duplication by factoring out the code building load.php requests into ResourceLoader::makeLoaderURL() and makeLoaderQuery() 2011-09-13 20:36:24 +00:00
Roan Kattouw
f4f3107209 Fix the fixme on r88053: dependency handling was broken in debug mode in certain cases. More specifically, if A is a file module that depends on B, B is a wiki module that depends on C and C is a file module, the loading order is CBA (correct) in production mode but was BCA (wrong) in debug mode. Fixed this by URL-ifying scripts and styles for those modules in debug mode, as I said to on CR. What this means is that the initial debug=true request for a module will now always return arrays of URLs, never the JS or CSS itself. This was already the case for file modules (which returned arrays of URLs to the raw files), but not for other modules (which returned the JS and CSS itself). So for non-file modules, load.php?modules=foo&debug=true now returns some JS that instructs the loader to fetch the module's JS from load.php?modules=foo&debug=true&only=scripts and the CSS from ...&only=styles .
* Removed the magic behavior where ResourceLoaderModule::getScripts() and getStyles() could return an array of URLs where the documentation said they should return a JS/CSS string. Because I didn't restructure the calling code too much, the old magical behavior should still work.
* Instead, move this behavior to getScriptURLsForDebug() and getStyleURLsForDebug(). The default implementation constructs a single URL for a load.php request for the module with debug=true&only=scripts (or styles). The URL building code duplicates some things from OutputPage::makeResourceLoaderLink(), I'll clean that up later. ResourceLoaderFileModule overrides this method to return URLs to the raw files, using code that I removed from getScripts()/getStyles()
* Add ResourceLoaderModule::supportsURLLoading(), which returns true by default but may return false to indicate that a module does not support loading via a URL. This is needed to respect $this->debugRaw in ResourceLoaderFileModule (set to true for jquery and mediawiki), and obviously for the startup module as well, because we get bootstrapping problems otherwise (can't call mw.loader.implement() when the code for mw.loader isn't loaded yet)
2011-09-13 17:13:53 +00:00
Chad Horohoe
94245538ff Merge live hack - bumping version of minified stuff 2011-08-01 23:20:58 +00:00
Roan Kattouw
a2afc812ca Make mw.user.options and mw.user.tokens work in debug mode in IE. Now that mw.user is a separate module, we have to make these depend on that and make sure dependencies are actually processed.
* Make ResourceLoaderUserOptionsModule and ResourceLoaderUserTokensModule depend on mw.user
* Load mw.user.{tokens,options,groups} load as TYPE_COMBINED instead of TYPE_SCRIPT. The latter wouldn't wrap the code in mw.loader.implement()
** ...but make sure 'user' (user scripts) is excluded, that one needs to not be wrapped in a closure
* Make TYPE_COMBINED actually work in makeResourceLoaderLink()
* Add a comment in makeModuleResponse() to explain what the weird is_array( $scripts ) stuff is all about
* Add FIXME about how mw.user.options should split off the CSS part into a separate module
2011-07-28 05:48:57 +00:00
Krinkle
cc21627b4d [ResourceLoader 2]: Add support for multiple loadScript sources
Front-end:
* New mw.loader method: addSource(). Call with two arguments or an object as first argument for multiple registrations
* New property in module registry: "source". Optional for local modules (falls back to 'local'). When loading/using one or more modules, the worker will group the request by source and make separate requests to the sources as needed.
* Re-arranging object properties in mw.loader.register to match the same order all other code parts use.
* Adding documentation for 'source' and where missing updating it to include 'group' as well.
* Refactor of mw.loader.work() by Roan Kattouw and Timo Tijhof:'
-- Additional splitting layer by source (in addition to splitting by group), renamed 'groups' to 'splits'
-- Clean up of the loop, and removing a no longer needed loop after the for-in-loop 
-- Much more function documentation in mw.loader.work()
-- Moved caching of wgResourceLoaderMaxQueryLength out of the loop and renamed 'limit' to 'maxQueryLength

Back-end changed provided through patch by Roan Kattouw (to avoid broken code between commits):
* New method in ResourceLoader: addSource(). During construction of ResourceLoader this will be called by default for 'local' with loadScript property set to $wgLoadScript. Additional sources can be registered through $wgResourceLoaderSources (empty array by default)
* Calling mw.loader.addSource from the startup module
* Passing source to mw.loader.register from startup module
* Some new static helper methods

Use:
* By default nothing should change in core, all modules simply default to 'local'. This info originates from the getSource()-method of the ResourceLoaderModule class, which is inherited to all core ResourceLoaderModule-implementations (none override it)
* Third-party users and/or extensions can create new classes extending ResourceLoaderModule, re-implementing the getSource-method to return something else.

Basic example:
$wgResourceLoaderSources['mywiki'] = array( 'loadScript' => 'http://example.org/w/load.php' );
class MyCentralWikiModule extends ResourceLoaderModule {
	function getSource(){
		return 'mywiki';
	}
}
$wgResourceModules['cool.stuff'] => array( 'class' => 'MyCentralWikiModule' );

More complicated example
// imagine some stuff with a ForeignGadgetRepo class, putting stuff in $wgResourceLoaderSources in the __construct() method
class ForeignGadgetRepoGadget extends ResourceLoaderModule {
	function getSource(){
		return $this->source;
	}
}

Loading:
Loading is completely transparent, stuff like $wgOut->addModules() or mw.loader.loader/using both take it as any other module and load from the right source accordingly.


--
This commit is part of the ResourceLoader 2 project.
2011-07-26 21:10:34 +00:00
Sam Reed
16842c0b73 Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits (2/3), so hopefully reviewable in CR...
2011-06-17 16:05:05 +00:00
Roan Kattouw
8dab43f703 (bug 28840) URLs with dots break because of IE6 security check
* Replace the overly paranoid regex with a function that simulates IE6's behavior
* Remove the UA check in isPathInfoBad(), was causing more problems than it was worth
* Revert r87711, going back to using dots for dots in ResourceLoader URLs, instead of exclamation marks
* Append &* to ResourceLoader URLs. * is an illegal character in extensions, and putting it at the end of the URL ensures that both IE6 and our detection function will deem the URL to have no extension (unless something like .html? appears in the query string, but in that case we're screwed no matter what)
2011-05-26 09:49:45 +00:00
Sam Reed
16c194d0ae Fixup/add documentation
Remove trailing whitespace
2011-05-21 17:45:20 +00:00
Platonides
28e6771032 Follow up r88053. This was trying to throw the return value of a function called MWException. 2011-05-15 12:36:21 +00:00
Trevor Parscal
e6bee6f043 Added direct file loading functionality to debug mode for both scripts and styles, with callbacks for module state changes (changing to ready) and executing of jobs and modules awaiting dependency resolutions. These changes also provide a way to used mw.loader.implement with arrays of URLs for the scripts and styles arguments, which will make it possible to implement modules using user scripts. This probably solves bug #27023 - tests to verify that will be coming soon. 2011-05-14 12:15:58 +00:00
Roan Kattouw
104c5ddfe9 Followup r87711: add ! to the forbidden characters list for module names, per CR 2011-05-14 09:24:24 +00:00
Krinkle
49ce5de7d9 Creating a way to toggle mw.config LEGACY_GLOBALS from LocalSettings (bug 28916).
* I thought a while for a way to somehow get that global variable from php to the start of the main mediaWiki object creation. Considered using a (temporary) global variable and deleting afterwards, but that looked like a hack and wasn't sure about the cross-browser functioning of it. Instead ended up by moving it to the startUp module where other global variables are accessed as well. This seems to work pretty good.

* Can be toggled from LocalSettings by setting $wgLegacyJavaScriptGlobals.
* Changed some usages of mediaWiki to use the global mw alias instead.
2011-05-10 23:17:13 +00:00
Roan Kattouw
950cf2cb86 (bug 28840) Commit patch by bawolff that encodes dots in ResourceLoader module names as exclamation marks in the generated URLs, so as to avoid triggering the recently added IE security measure and causing a blank 403 response. This broke RL in various ways for IE users.
This is by no means intended to be permanent, but it's the best way to unbreak RL for IE users while we work out how to fix this properly.
2011-05-09 13:10:06 +00:00
Roan Kattouw
7fee86c38e Per bug 28738 comment 4, pack ResourceLoader URLs by encoding foo.bar|foo.baz|bar.baz|bar.quux as foo.bar,baz|bar.baz,quux
* Expand these URLs in ResourceLoaderContext
* Build and emit these URLs in OutputPage::makeResourceLoaderLink() and in mw.loader
* Throw an exception in ResourceLoader::register() for module names that contain pipe characters or commas. Commas need to be forbidden for this packing feature to work. Pipes were already forbidden but weren't checked for
2011-05-05 13:46:47 +00:00
Krinkle
373859bafe mw.loader fixes
* Renaming locally declared function "request" to "getScriptTag" to avoid confusion or conflict with the other local "request" function inside the mw.loader closure
* (bug 26804) Code clean up ($skin was generated locally already)
2011-05-04 20:58:14 +00:00
Trevor Parscal
2cff94d097 Added charset property to HTTP Content-Type fields when serving CSS and JavaScript via ResourceLoader - resolves bug #28208. 2011-04-01 20:48:50 +00:00
Roan Kattouw
b066397f10 Bump RL filter version to 4 to keep it in sync with the cluster. WMF-centrism, I know, sue me ;) 2011-03-23 17:45:00 +00:00
Roan Kattouw
15bcd02d4c (bug 27054) Implicit end of statement can break stuff when files are combined. Applied patch by Paul Copperman: add a semicolon to the end of every module when combining; this'll terminate any unterminated final statement, and otherwise create a harmless empty statement. 2011-03-14 14:25:23 +00:00
Roan Kattouw
47d5ad564b Followup r83885: implement maximum line length and statement termination (each statement on its own line) in JavaScriptMinifier. Also add globals for these things and update minify.php for these new config vars. 2011-03-14 13:24:30 +00:00
Roan Kattouw
867fc1cba8 (bug 27528) Incorporate Paul Copperman's minifier 2011-03-14 11:44:33 +00:00
Krinkle
e89aab93a3 mw.loader.implement now calls script without setting mw to mediaWiki since this is already globally avaiable
* Also shortens a few wrapper functions the same way
* Partial revert of r82496. Apparantly mw-alias is not available in startUp module. TODO: Find out why ?

(See also r82496 commit message)
2011-02-19 23:52:11 +00:00
Krinkle
b2378a694c Using the mw alias for mediaWiki in core. Saves bandwidth and makes sense (there's no point in a wrapper function for ($,mw) if we use jQuery and mediaWiki inside of it).
TODO: Since the alias is globally available from the start, the 'mw' argument in the wrapper is redundant, so that should be removed at some point as well.
2011-02-19 22:59:44 +00:00
Tim Starling
a1717b4953 Add the cache key to the filter output, like what we do with the parser cache, to make it easier to debug filter issues. 2011-02-18 05:55:09 +00:00
Roan Kattouw
02bbd866ae Version the minifier cache in ResourceLoader 2011-02-17 22:13:52 +00:00
Roan Kattouw
14c43476c6 Never serve 304s from RL in debug mode. This causes inadvertent caching of debug responses 2011-02-12 23:41:28 +00:00
Platonides
34bfd1dd6a Add profiling to the whole ResourceLoader::makeModuleResponse 2011-02-10 16:44:57 +00:00
Sam Reed
e42253eb45 Minor documentation tweaks/improvements 2011-02-08 23:09:22 +00:00
Sam Reed
5d5a3938bb Add missing wfProfileOut( __METHOD__ ); 2011-02-08 22:01:34 +00:00
Tim Starling
9bd321231b Fix bug from r73645: setMsgBlobMtime() requires its timestamp parameter to be a UNIX timestamp, which $row->mr_timestamp isn't. This was causing incorrect versions in the client-side module list, resulting in requests for URLs with "version=NaNNaNNaNTNaNNaNNaNZ", which Michael has been occasionally complaining about. 2011-02-08 05:33:17 +00:00
Trevor Parscal
951103eeb2 Resolved bug 26791 by replacing JSMin with a new library called JavaScriptDistiller, which is an improved version of the minification bits from JavaScriptPacker, an LGPL library. Good news - it's 2x faster than our optimized JSMin anyways, and more configurable to boot. 2011-01-20 21:57:01 +00:00
Roan Kattouw
579e549add Followup r73686: make private modules really private (i.e. Cache-Control: private instead of s-maxage=0 , for paranoia) and make debug requests really uncacheable (with no-cache, and a Pragma: no-cache for HTTP 1.0 clients) 2011-01-19 19:31:14 +00:00
Roan Kattouw
ad9586edaa Followup r78924: keep track of exception/warning comments separately, to prevent them from being eaten by the minifier. This also prevents filter cache pollution. Additionally, uncomment some wrongfully commented-out code introduced in r78924, and add newlines after exception/warning comments 2011-01-09 12:29:02 +00:00
Roan Kattouw
8edf949acd Attempt at fixing bug 26370, which seems to be an infinite loop caused by ob_get_level() never going all the way down to 0 no matter how many output buffers we destroy. Use a for loop instead 2011-01-08 15:41:55 +00:00
Roan Kattouw
fb80a53b1b (bug 26497) printable=yes and handheld=yes request parameters were broken. Fixed this in a bit of an ugly way, by propagating these parameters to load.php and running OutputPage::transformCssMedia() on it there. This revision also fixes the fact that ResourceLoader ignored $wgHandheldForIPhone, and no longer wraps styles in @media all { } because it's useless and breaks @import (which can't be used inside @media ; this is bug 26478) 2011-01-07 20:22:50 +00:00
Roan Kattouw
bd93eeb85f (bug 26507) Wrap all ResourceLoader-served JS in (function($, mw) { code here })(jQuery, mediaWiki) so modules can always use $ as an alias for jQuery even if it's been unset in the global scope with jQuery.noConflict() 2010-12-30 12:22:39 +00:00