Commit graph

42 commits

Author SHA1 Message Date
Sam Reed 0b1347bdd2 SFH_OBJECT_ARGS was added pre 1.12...
Kill ancient back compat, and code where unused
2011-12-19 00:38:10 +00:00
Alexandre Emsenhuber f4d9df85d5 * Only get the LinkCache instance when really necessary
* Do not assign a variable inside a condition check
2011-12-18 19:00:53 +00:00
Brian Wolff c763bf6ce1 (bug 32351) Make #time[l] support explicitly specified timezones. Patch by Van de Bugger.
This would make something like {{#time:H:i:s| 9:30 January 1, 2012 MST}} convert the time from 9:30 mountatin standard time to whatever it is in UTC.

I made one minor change from the patch on bugzilla in changing an @ to a wfSuppressWarnings. (The @ was already in the code, it wasn't introduced by the patch).
2011-12-07 20:52:41 +00:00
Sean Colombo a76aa995fe ParserFunctions: The third param turned out to have the same issue as the second (was throwing warnings in production since empty-strings were making their way in). Followup to r103834. 2011-11-21 21:18:18 +00:00
Sean Colombo 4d02a43a53 ParserFunctions: made #sub stronger against bad params (was throwing a ton of warnings in production at Wikia). 2011-11-21 21:09:19 +00:00
Chad Horohoe e188af9e04 Swap ParserFuncs to use the timezone funcs (like r60825) rather than putenv() magic.
putenv( 'TZ=foo' ) doesn't work with the 5.4 beta ;-)
2011-09-29 18:20:10 +00:00
Tim Starling e764705f57 Revert r92572: Language::isValidBuiltInCode() only rejected the empty string since r95646, so the check is necessary in this backwards-compatible extension. Needs backport per bug 31203. 2011-09-27 22:47:20 +00:00
Ryan Kaldari b681f84927 follow up to r87308 - fix redundancy 2011-07-19 20:31:38 +00:00
Ryan Kaldari 81d74aca19 follow up to r87308 - defensive programming for bogus language codes 2011-07-19 20:29:17 +00:00
Ryan Kaldari a3dd6784c8 better language handling - abandon magic language switch in favor of using int:lang as parameter, use parser->getFunctionLang() instead of wgContLanguage in case of use in interface messages 2011-05-02 23:30:05 +00:00
Ryan Kaldari 752dd28e01 fix issues from r86927, user language and years over 9999 2011-05-02 22:21:56 +00:00
Ryan Kaldari cb39cec9d6 adding language support to #time parser function, per bug 28655 2011-04-26 00:26:12 +00:00
Ryan Kaldari f9578f4d6a fix for bug 28655 - #time interpreting years incorrectly 2011-04-24 01:10:04 +00:00
Sam Reed 956982c04a More function documentation 2011-04-15 17:44:19 +00:00
Sam Reed 64dd1d254e Made checkLength static to fix many STRICT errors 2011-04-13 14:17:43 +00:00
Paul Copperman 3350ea8f2d Make ParserFunctions work with HipHop.
* When using HipHop, is_callable() returns false for objects which have only a __call() method instead of the requested one.
* Work around this by removing the ParserFunctions_HookStub hack.
* To retain the behavior that the code of ParserFunctions_body.php is only loaded when needed, turn it into a static class.
* Defer the registering of the ParserClearState hook until a relevant function is called.
2011-04-11 17:27:51 +00:00
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