Commit graph

63 commits

Author SHA1 Message Date
Brad Jorsch b386038c00 #switch should not match #default as a prefix
For example, "{{#switch:x|#defaultWTF? = This is crazy}}" should not
return "This is crazy".

Bug: 67871
Change-Id: Ie3f2e6b254b9f44028156268bd8d67aa3dd1cc62
2014-07-11 18:16:11 +00:00
Marcus Brinkmann 23dd608020 Fix #switch #default to match next (not last) named parameter.
Bug: 23192
Change-Id: I3a726b3aacb2a598f79c0dbebaa4f400ee2d9aa2
2014-07-11 14:02:12 -04:00
Jackmcbarn b34f264e0c Unstub $langObject
The first time we use $langObject, it's a function call with a parameter
by reference, so it needs to be unstubbed first.

Change-Id: I43cdb0a8b2728d0f69a11fd778c6a3ff03487ef3
2014-07-03 16:03:14 -04:00
Brian Wolff 3c3e0751d7 Decode html entities before comparing strings in #ifeq: and #switch
This makes foo's equal to foo's. This is particularly important
since {{PAGENAME}} and friends html encode certain characters.

This change should be communicated to users before it hits wikis.
I don't think anyone is relying on the current behaviour, but
you never know.

Bug: 35628
Change-Id: I0035ac541d22491fcf15f55f2589aaab394ed0ed
2014-06-25 16:21:58 -03:00
jenkins-bot 016d9eac4b Merge "Add a TTL to #time and #timel output" 2014-06-24 22:54:38 +00:00
Jackmcbarn 334f1f0ee3 Add a TTL to #time and #timel output
Set the appropriate TTL when using #time or #timel. Needs I412febf3 and
I3f5a80aa in core to function.

Change-Id: I2e8b8918482b0b3f4adf154af795b6bb53b99497
2014-06-01 14:16:43 -04:00
Jackmcbarn f7bd89e435 Allow calling #expr from Lua without the parser
Add mw.ext.ParserFunctions.expr, allowing #expr to be used without needing
to use frame:callParserFunction.

Change-Id: I64c78fafad7da503b141efb36da64c3e3d8501a5
2014-05-05 17:58:40 +00:00
umherirrender 0930b80e05 mb_substr() expects parameter 2 to be long, string given
Adding missing intval as suggested in bug 51834

Bug: 51834
Change-Id: I0bc8d612dc52d32e2cd616325e800b95c4efa23f
2014-01-31 17:03:50 +01:00
Liangent 2448ee79ab (bug 22808) Don't count "expensive" calls for cached titles
Bug: 22808
Change-Id: Ie4dd9fd647dc79a2b31bc44ef8b6a641b54cfb78
2013-05-29 03:27:16 +00:00
Brad Jorsch d335043d74 Don't pass negative years to Language::sprintfDate
Language::sprintfDate cannot handle negative years, so don't pass them.
Return an appropriate error instead.

Change-Id: I87ce19a32312bb7db0740b4daddb995132eef683
2013-04-19 17:59:31 -04:00
Brad Jorsch 54940c51d6 (bug 33454) Add format characters for timezone
The {{#timel:}} parser function lacks any way to output the timezone
used, and generates incorrect output for the 'c', 'r', and 'U'
formatting characters. This uses the timezone support added to core
Language::sprintfDate in Iea1f7842 to fix that.

Bug: 33454
Change-Id: I71f594132ce48140a95bd85e16183c4a1162ebef
2013-04-02 23:11:05 +00:00
Siebrand Mazeland 5dee345880 ParserFunctions extension maintenance.
* Use Message class instead of wfMsg* methods.
* Replace additional deprecated methods.
* Fixed incorrect tag in i18n file.
* Update .gitignore.

Conflicts:
	ParserFunctions.i18n.php

Change-Id: If21300c11ec628506cb56550bc91a24a5d7c45d2
2012-10-03 20:58:43 +00:00
umherirrender d7668a3581 Use Parser::incrementExpensiveFunctionCount direct for ifexist
No need to do it self and now the limit of the ParserOptions is used.

Change-Id: Id13796d0424fb3b5501a774e1ace3ea065864e49
2012-10-02 23:47:52 +00:00
umherirrender 99b150fab4 Cleanup I730624f4: Bug 40039 - Remove ConvertParser from ParserFunctions
Remove unused vars and dead entries for classes and tests

Change-Id: I0920f0294043fa1cca0ca5622fb7eae4a8c61fcb
2012-09-08 19:30:30 +02:00
Reedy 7a3619ea8d Bug 40039 - Remove ConvertParser from ParserFunctions
Change-Id: I730624f455dcd8cf0375b9147efe4abee5b203bb
2012-09-06 15:44:12 +01:00
Reedy fdd7c091bd Minor documentation additions
Change-Id: I876de41b2c81d93df34ee2a8222aff6dc8176aae
2012-07-23 20:56:17 +01:00
Mark A. Hershberger fb5864083d w/s 2012-02-06 04:37:05 +00:00
Max Semenik 2aacab3186 ParserFunctions: made {{#time}} respect parser's timestamp, just as {{CURRENTDATE}} and friends do 2011-12-19 11:18:13 +00:00
Max Semenik d605269ce8 ParserFunctions: ditch PHP pre 5.2 compatibility 2011-12-19 10:51:39 +00:00
Sam Reed 8e61fa2f32 Flesh out documentation
Remove some more < 1.12 back compat code
2011-12-19 00:54:31 +00:00
Sam Reed 1eec35dabd Fix function name typo "date_defaulttimezone_get()" to "date_default_timezone_get()" from r105459 2011-12-19 00:51:36 +00:00
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