aboutsummaryrefslogtreecommitdiffstats
path: root/includes/MagicWord.php
Commit message (Collapse)AuthorAgeFilesLines
* Fix various documentation related to null typesUmherirrender2022-02-261-1/+1
| | | | | | | | The functions returning null or the class property is set explict null Found by phan strict checks Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
* Use @internal instead of @private per policydaniel2020-06-261-1/+1
| | | | | | | | https://www.mediawiki.org/wiki/Stable_interface_policy mandates the use of @internal. The semantics of @private was never properly defined. Bug: T247862 Change-Id: I4c7c6e7b5a80e86456965521f88d1dfa7d698f84
* Rename MagicWordwgVariableIDs hook to GetMagicVariableIDsC. Scott Ananian2020-06-101-1/+4
| | | | | | | | | | | | This makes the hook name consistent with GetDoubleUnderscoreIDs, and is part of a set of related documentation changes clarifying the difference between "magic words" (a localization infrastructure) and the various functions which use magic words for localization, such as parser functions, double underscore variables, magic variables, etc. See also I621c888e3790a145ca9978f6b30ff1a8f685b64c. Change-Id: Ie2a6df4b179a360fb7cdfb219e915bedff501d1d
* Miscellaneous documentation updatesDannyS7122020-02-161-1/+1
| | | | | | | Update references from .txt to .md when files have moved, a few other tweaks, no changes to code. Change-Id: I0bfd38c47b9fb0fc11ae98a0a674af66fb4c5a84
* Drop MagicWord static getters, deprecated in 1.32James D. Forrester2020-01-171-57/+0
| | | | | | Depends-On: I7c4400f5f84088572bad2f2aac09f24203c9bb89 Depends-On: I8322471cf35d387ebd320116360bc60e6296ec51 Change-Id: I9c790a8438f88e3a731781e25408e6bdd5f7f894
* Clean up spacing of doc commentsUmherirrender2019-08-051-2/+2
| | | | | | Align the doc stars and normalize start and end tokens Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
* Simplify by using ?: operatorFomafix2019-04-151-5/+1
| | | | Change-Id: I2851cc51c9e05dd0599733be5af39e19f12b52e2
* Hard-deprecate MagicWord static methodsAryeh Gregor2019-04-091-0/+5
| | | | | Bug: T200247 Change-Id: Ib36e78274f42ddbeaa7801cc8bad77b991a4a1aa
* Update MagicWord to use ContentLanguageAryeh Gregor2018-08-011-5/+12
| | | | | Bug: T200246 Change-Id: I9f17142d25bc851c973bebe27e6cbc5be8b70729
* MagicWordFactory to replace MagicWord static members/methodsAryeh Gregor2018-07-301-196/+15
| | | | | | | | | | | | | | Static members of MagicWord have been removed. Static methods are soft-deprecated and forward to the factory. They will be hard-deprecated when all callers are removed from core. MagicWord::clearCache() has been removed. Instead, call resetServiceForTesting( 'MagicWordFactory' ) on your MediaWikiServices object. Change-Id: Ie061fe90f9b9eca0cbf7e8199d9ca325c464867a Bug: T200247
* Fix PhanTypeMismatchDeclaredParamUmherirrender2018-07-071-1/+1
| | | | | | Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
* Use PHP 7 '<=>' operator in 'sort()' callbacksBartosz Dziewoński2018-05-301-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser, and `0` if they are equal, which are exactly the values 'sort()' callbacks are supposed to return. It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]` to sort arrays of objects first by 'x', and by 'y' if they are equal. * Replace a common pattern like `return $a < $b ? -1 : 1` with the new operator (and similar patterns with the variables, the numbers or the comparison inverted). Some of the uses were previously not correctly handling the variables being equal; this is now automatically fixed. * Also replace `return $a - $b`, which is equivalent to `return $a <=> $b` if both variables are integers but less intuitive. * (Do not replace `return strcmp( $a, $b )`. It is also equivalent when both variables are strings, but if any of the variables is not, 'strcmp()' converts it to a string before comparison, which could give different results than '<=>', so changing this would require careful review and isn't worth it.) * Also replace `return $a > $b`, which presumably sort of works most of the time (returns `1` if `$b` is lesser, and `0` if they are equal or `$a` is lesser) but is erroneous. Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
* Updated type and function docs for MagicWord.phpUmherirrender2017-10-021-12/+31
| | | | Change-Id: I46ebd315a99b1677ff89ba392c0072b41bbeb36d
* Remove deprecated MagicWord::replaceMultiple()Max Semenik2017-08-141-27/+0
| | | | | | wfDeprecated since 1.25, not used anywhere. Change-Id: I09fd362a3d795328ffc12572025702ef9b951378
* Add missing & to @param documentation to match functon callUmherirrender2017-08-111-4/+4
| | | | Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
* build: Update mediawiki/mediawiki-codesniffer to 0.10.1Kunal Mehta2017-07-221-1/+1
| | | | | | | | | And auto-fix all errors. The `<exclude-pattern>` stanzas are now included in the default ruleset and don't need to be repeated. Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
* Merge "Miscellaneous indentation tweaks"jenkins-bot2017-02-281-2/+2
|\
| * Miscellaneous indentation tweaksBartosz Dziewoński2017-02-271-2/+2
| | | | | | | | | | | | | | | | | | | | I was bored. What? Don't look at me that way. I mostly targetted mixed tabs and spaces, but others were not spared. Note that some of the whitespace changes are inside HTML output, extended regexps or SQL snippets. Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
* | includes: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-211-1/+1
|/ | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
* Replace use of &$thisBrad Jorsch2017-01-311-2/+2
| | | | | | | | | Use of &$this doesn't work in PHP 7.1. For callbacks to methods like array_map() it's completely unnecessary, while for hooks we still need to pass a reference and so we need to copy $this into a local variable. Bug: T153505 Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
* Add a new {{PAGELANGUAGE}} variable for use in wikitextdivadsn2017-01-071-0/+1
| | | | | | | Returns the language code of the page being parsed. Bug: T59603 Change-Id: I229edd6251cf1120b3395d1811dbb9d96d9cd8ee
* Clean up array() syntax from docs, part VIAmir Sarabadani2016-09-121-5/+5
| | | | Change-Id: Ib0eea494e2065c7ab356dc45fd174544a9c1c942
* Add access modifiers to MagicWord.phpaddshore2016-03-011-39/+39
| | | | Change-Id: I3588d9d2c17203ec3ff11736cd6ce84f687677a5
* Move MagicWordArray class to own fileaddshore2016-03-011-308/+0
| | | | Change-Id: I9ba602da77f1c8d4270d8ae10d03e82a3197e5b1
* Convert all array() syntax to []Kunal Mehta2016-02-171-37/+37
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Log warnings on on preg_* failures in MagicWordArray::matchAndRemove()Gergő Tisza2015-10-291-2/+19
| | | | | | | Softer version of I3840a56adc0a6e50963b930051892491f8e90245. Bug: T115514 Change-Id: Idb297a31b17928a0151476879294eedfbec0d744
* Revert throwing exceptions on preg_* failuresGergő Tisza2015-10-291-14/+2
| | | | | | | | | This reverts I3840a56adc0a6e50963b930051892491f8e90245 which threw exceptions on broken UTF-8 in $text. Bug: T115514 Bug: T117066 Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362
* Include preg_last_error() in error message when preg_* failsGergő Tisza2015-10-291-2/+4
| | | | | | Bug: T115514 Bug: T117066 Change-Id: I1d13f8542a4cf11c8e87cd4f6a983fa852dfdf1e
* Throw Exceptions on preg_* failures in MagicWordArray::matchAndRemove()Kunal Mehta2015-10-231-2/+12
| | | | | | | | | There are a lot of other cases in this file alone that need to be fixed (e.g. (bool)preg_match), but those should be fixed in a more systematic way like a wrapper function. Bug: T115514 Change-Id: I3840a56adc0a6e50963b930051892491f8e90245
* Fix use of preg_match_all in MagicWord.phpumherirrender2015-09-101-4/+6
| | | | | | | Init variable before use Check return value to avoid notice on failures Change-Id: I5cecae32f7672d748706c7a72bf01e9aee65e6d4
* Remove unused private field in MagicWordArrayjeroendedauw2015-09-101-3/+0
| | | | Change-Id: Ib7a0c2834314e9c8db442956230d389e51dbb256
* Merge "Remove obvious function-level profiling"jenkins-bot2015-01-071-3/+0
|\
| * Remove obvious function-level profilingChad Horohoe2015-01-071-3/+0
| | | | | | | | | | | | | | | | | | | | | | Xhprof generates this data now. Custom profiling of various sub-function units are kept. Calls to profiler represented about 3% of page execution time on Special:BlankPage (1.5% in/out); after this change it's down to about 0.98% of page execution time. Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
* | Marked replaceMultiple() as deprecatedEvan McIntire2015-01-071-1/+2
|/ | | | | | MagicWord::replaceMultiple() is completely unused in both core and all extensions on gerrit, so it is being marked as deprecated. Change-Id: I6289a36351a2cbc47a0cad237cc985e5c3136773
* Replace wfRunHooks calls with direct Hooks::run callsAaron Schulz2014-12-101-2/+2
| | | | | | * This avoids the overhead of an extra function call Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
* Remove hitcounters and associated codeChad Horohoe2014-10-201-2/+0
| | | | | | | | | The hitcounter implementation in MediaWiki is flawed and needs removal. For proper metrics, it is suggested to use something like Piwik or Google Analytics. RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Removing_hit_counters_from_MediaWiki_core Change-Id: I0e5006a7e8a09c800f8fa4effa9399e8afdd7a57
* Add missing @return to function docsumherirrender2014-08-231-0/+3
| | | | Change-Id: I45b9d02f94ecc58372268ec5e6a0b572a0b7e2a9
* Support {{!}} as a magic wordJackmcbarn2014-06-261-0/+1
| | | | | | | Add {{!}} as a magic word that expands to a pipe. Parsoid already does this, so we know it isn't going to cause major breakage. Change-Id: I1f857417d224d6443504074a5add852df3975b89
* MagicWord: Fix an indentBartosz Dziewoński2014-05-231-1/+1
| | | | Change-Id: I3640fb7a783a68c43a1249b87ef04e587dd0cfd5
* Make phpcs-strict pass on includes/ (6/~10)Siebrand Mazeland2014-05-121-19/+64
| | | | Change-Id: I566183b5d660a55bb3b2aa7186aaed5355ead2c6
* Fix return type documentation for getCacheTTL()Siebrand Mazeland2014-05-101-1/+1
| | | | Change-Id: I57e85351503897f8f8febb2fb49942a2ddd251e6
* Fixed some @params documentation (includes/*)umherirrender2014-04-221-30/+30
| | | | | | | | | Swapped some "$var type" to "type $var" or added missing types before the $var. Changed some other types to match the more common spelling. Makes beginning of some text in captial. Also added some missing @param. Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
* Fix spacing after @param and friends in commentsumherirrender2014-04-051-1/+1
| | | | | | | Searched for: \@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,} Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
* Raw option of parser functions should match complete wordumherirrender2014-01-121-0/+27
| | | | | | | | | The MagicWord raw was not matched against the whole given string, which result in a raw output, when this was not intented. Fixing this by adding a new regex, which matches the string from start to end. Bug: 56199 Change-Id: I7781c415bd61447dd91872575877dd21f36fae9f
* Add CASCADINGSOURCES parser functionJackmcbarn2014-01-041-0/+1
| | | | | | | | Add {{CASCADINGSOURCES}}, which gives a list of cascading-protected pages that cause a given page to be protected. This is an expensive parser function. Change-Id: I0e9556d53d9a78bc02848c775cb667294726cea1
* Make MagicWordArray compatible with PCRE 8.34+Kevin Israel2013-12-311-1/+3
| | | | | | | | | | | | | | | In PCRE 8.34, a subpattern's name must not start with a digit; work around this by replacing digits in the synonym's index with letters. Amazingly, this part of the name seems to have the sole purpose of ensuring uniqueness; none of the matching functions actually use it for anything. Adding a single-letter prefix was considered, though it would risk breaking extension code that may have used 29- or 30- character magic word IDs. (PCRE limits subpattern names to 32 characters.) Likewise, moving the magic word's ID to the front would not work if it were to start with a digit. Bug: 58640 Change-Id: Ic69f9000addbf18c4747105187e6f13191828fbb
* Added {{REVISIONSIZE}} variable to get the current size of a revision.umherirrender2013-09-211-0/+1
| | | | | | | | | | | | | | This avoids giving the own page name to {{PAGESIZE:}} and allows PAGESIZE on subst: to give the size before save. Viewing a oldid page will give the corresponding size to that revision. (Like REVISIONUSER or REVISIONTIMESTAMP) This partially reverts Idfac13de37d05317f65e4131534543e66cf74873 because there is no need to let PAGESIZE handle extra, when the given title is the own page. Change-Id: If9e608d54904c21ac6b095e91ff6e0a15da0fb4c
* MagicWord: Remove some commented-out codeMatmaRex2013-07-011-2/+1
| | | | Change-Id: I62014cd09b4033be0c958da2527911368fff141a
* Fixed spacing and removed unneeded parenthesisumherirrender2013-05-171-3/+3
| | | | | | | | Added spaces after/before parenthesis Removed unneeded parenthesis around some statements Broke a long line Change-Id: I7fbe129f7bbf524dd0598ece2a9708643f08453b
* Introducing a new variable {{ROOTPAGENAME}}blotmandroid2013-04-241-0/+2
| | | | | | | | | | | | | | | Introduced a new variable ROOTPAGENAME which has similar content like BASEPAGENAME. ROOTPAGENAME only contains the name of the topmost page without namespace, e.g. for "User:Name/Article/Subarticle" it should be "Name". BASEPAGENAME would be "Name/Article" here. Update : fixed indentation in maintenance/fuzz-tester.php Added to RELEASE-NOTES-1.2.2 Bug: 6747 Change-Id: I71ef0a15c95c9145462f3aa7fdb3ed11dac79265