Commit graph

26 commits

Author SHA1 Message Date
Aaron Schulz 022503d1b7 Follow-up changes to r84610:
* Cleaned up mImageTimeKeys format
* ImageMap: Removed redundant addImage call (makeImage handes this)
* ParserFunctions: added time/sha1 to addImage() call
* Removed excess ampersands in hooks
* Added some function doc comments
2011-04-04 01:22:08 +00:00
Happy-melon 7ec54c6cfc Follow-up r81074 CR:
* Use autoloader for ConvertParser, and ExprParser which the code was cloned from
* Fix PHP 5.1 compatibility, while there's no requirement for us to keep it, there's also no need to break it unnecessarily, and it's a really trivial fix in this case.
* Tidy whitespace
* Use ConvertDimension::getLocalisedName() for the dimensionmismatch error, as intended
2011-01-27 17:34:37 +00:00
Happy-melon 65e9e69202 (bug 235) parser function for conversion of units of measurement.
[[Template:Convert]] on enwiki is a behemoth of a construction that just about manages to do this sort of conversion, taking {{convert|5|mi|km}} and outputting "5 miles (8 km)", etc.  To port this to another wiki requires copying over three and a half thousand subtemplates.  The additional load produced by including numerous copies of this template is measurable on large pages on enwiki, and it eats voraciously into the template limits.

This revision introduces {{#convert: 5 mi | km }}, outputting "8 km" or thereabouts.  See http://www.mediawiki.org/wiki/User:Happy-melon/Convert for more details, or look at the examples in the parser tests.  

In a very rough profile, comparing 50 calls to {{convert}} verses the same 50 calls to the wrapper template shown at the link above, the parser function implementation reduces page load time by 72%, preprocessor node count by 83%, post-expand include size by 86% and template argument size by 97%.  More detailed profiling would probably reveal places where extra caching could improve performance further.

The primary reason for putting it in ParserFunctions instead of its own extension is availability: PFs are already available across the cluster, and it's accepted as an essential extension for any wiki wishing to emulate or mirror WMF content.  One less separate extension installed on the cluster is one less extension which has to be matched by reusers.  

It's still missing a lot of units, which I ran out of patience to copy from {{convert}}; I thought I'd get some feedback on the infrastructure first.
2011-01-27 00:13:10 +00:00
Sam Reed aa43a8cfe5 Document return type 2011-01-14 00:40:30 +00:00
Sam Reed 17b2757a6a More deprecated method call removals and updates 2010-10-29 15:32:44 +00:00
Siebrand Mazeland 20888253e0 * remove MediaWiki pre-1.8 compatibility and remove SprintfDateCompat.php
* bump version to 1.4.0
* run stylize.php
2010-10-02 22:36:34 +00:00
X! c0835f5836 (bug 22116) Add limit parameter to {{#explode:}}. Patch by Christopher Baker 2010-08-08 16:18:33 +00:00
Max Semenik 1b75afd18d (bug 19940) urldecode dropped during StringFunctions-ParserFunctions merger 2010-05-29 16:12:41 +00:00
Chad Horohoe 7d289782c8 Revert r66934 (Removing wfLoadExtensionMessages() from everything). I disagree on principle...we branch extensions for this very reason. But people want trunk extensions compatible for several versions back, meh. 2010-05-27 15:56:53 +00:00
Chad Horohoe 1813ce38bb Large commit. Removed 800+ references to no-op wfLoadExtensionMessages() 2010-05-26 22:25:32 +00:00
Brion Vibber 49aef28f87 Clean up some old PHP 4-style references passing $parsers around in ParserFunctions. Caused PHP warning output when using some functions on PHP 5.3. 2010-04-16 11:00:07 +00:00
Alexandre Emsenhuber d37e2b09f0 Per Platonides, follow-up r63912: readd the removed line and remove the other one, since it's only used there 2010-03-20 16:39:03 +00:00
Alexandre Emsenhuber c60f90db7b * (bug 12901) #switch no longer expands node twice 2010-03-18 16:25:28 +00:00
Alexandre Emsenhuber 417248832f * (bug 22866) Cast returned value to numeric if possible to do the check since ExprParser::doExpression() returns a string, this was causing some bugs since "-0" (string) converted to boolean is "true" 2010-03-18 11:35:28 +00:00
Tim Starling 2a677438fa Revert r62436 and associated parser test. If you really want to make {{#ifexist:foo}} work the same way as [[File:foo]], which is presumably what bug 14779 is getting at, then you should do a proper job of it, and not introduce your own special #ifexist-specific syntax for specifying files. 2010-02-19 07:32:11 +00:00
Platonides f409f3f252 Follow up r62436 comments.
s/Title::newFromUrl/Title::newFromURL/
All these usages should be reviewed. Make it easy to grep using the canonical form.
Additionally fix the typo.
2010-02-13 23:58:30 +00:00
Platonides 9fbeadd46f (Bug 14779) {{#ifexist}} does not recognise URL encoded filenames
Solution provided by Umherirrender
2010-02-13 15:08:25 +00:00
Platonides 54e735a748 Follow-up r61154. Use StringUtils::escapeRegexReplacement() instead of manually replacing the characters. 2010-01-27 11:25:23 +00:00
Platonides df8dcaad5b Follow up r61149. Using preg_quote on $inReplaceTo replaces too much. However, we need to avoid \1 and $1 backreferences, since there won't be any (the user does no regex search, all parenthesis will be escaped). 2010-01-16 23:52:48 +00:00
Sam Reed 9e6fd9432e (bug 22115) Explode: Subject does not need to be quoted.
Apply supplied patch by Christopher Baker
2010-01-16 21:03:38 +00:00
Tim Starling bce79e84cb When $wgLocaltimezone is null, make #timel match the behaviour of {{LOCALTIME}} in trunk: use the server's default timezone instead of UTC. Won't throw E_STRICT after the r60825 change to Setup.php. 2010-01-08 01:51:00 +00:00
Yaron Koren 2aeda8c33d Fixed most of the calls to killMarkers() 2009-06-11 03:05:49 +00:00
Aryeh Gregor aa27785023 Make r51509 work with older MediaWiki versions too
After discussion with Tim.  The back-compat stuff here seems pretty
useless -- why can't people with old versions of MediaWiki just keep the
old feature sets, and upgrade MediaWiki to get new features for
extensions?  We branch extensions for a reason.
2009-06-05 17:14:03 +00:00
Aryeh Gregor 6905775132 Make default values fall through in switch
Bug 19093.  Previously {{#switch:foo|bar|#default=baz}} would behave
differently from {{#switch:foo|#default|bar=baz}}, even though they'd
behave identically if "#default" was replaced by "foo".

I changed switchObj but not switchHook.  In testing, switchObj was the
only method that seemed to be used, and I didn't want to make untested
changes to switchHook, so if that's used, the behavior may remain in
some cases.  It seems like code is duplicated between them -- whatever
the difference is, that should probably be factored out.

This passes all existing parser tests for #switch, of which there are
none, so don't blame me if it breaks something.  ;)
2009-06-05 16:53:59 +00:00
Aryeh Gregor 08bcb1bdc7 Style: "else { if" -> "elseif" 2009-06-05 16:31:43 +00:00
Tim Starling 5d97108615 * Disabled string functions by default with a configuration variable. Outlined my case for doing so.
* Defer loading the bulk of the code until a parser function is actually called. Necessary due to the recent large increase in code size. 
* Fixed the total disregard for parser state and object-oriented data flow in ExtParserFunctions::loadRegex().
2009-06-05 09:53:05 +00:00