Commit graph

246 commits

Author SHA1 Message Date
daniel
f59bf8a22f Use @internal instead of @private per policy
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
2020-06-26 14:14:23 +02:00
C. Scott Ananian
2c9d496268 Rename MagicWordwgVariableIDs hook to GetMagicVariableIDs
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
2020-06-10 12:28:20 -04:00
DannyS712
2e3bdb3498 Miscellaneous documentation updates
Update references from .txt to .md when files have moved, a few other
tweaks, no changes to code.

Change-Id: I0bfd38c47b9fb0fc11ae98a0a674af66fb4c5a84
2020-02-16 04:38:38 +00:00
James D. Forrester
112b6f305b Drop MagicWord static getters, deprecated in 1.32
Depends-On: I7c4400f5f84088572bad2f2aac09f24203c9bb89
Depends-On: I8322471cf35d387ebd320116360bc60e6296ec51
Change-Id: I9c790a8438f88e3a731781e25408e6bdd5f7f894
2020-01-17 01:22:59 +00:00
Umherirrender
2664eeb632 Clean up spacing of doc comments
Align the doc stars and normalize start and end tokens

Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
2019-08-05 22:29:50 +00:00
Fomafix
8a314d9b43 Simplify by using ?: operator
Change-Id: I2851cc51c9e05dd0599733be5af39e19f12b52e2
2019-04-15 15:05:00 +02:00
Aryeh Gregor
0762854560 Hard-deprecate MagicWord static methods
Bug: T200247
Change-Id: Ib36e78274f42ddbeaa7801cc8bad77b991a4a1aa
2019-04-09 11:51:36 +03:00
Aryeh Gregor
6142859029 Update MagicWord to use ContentLanguage
Bug: T200246
Change-Id: I9f17142d25bc851c973bebe27e6cbc5be8b70729
2018-08-01 10:39:33 +00:00
Aryeh Gregor
5189333c39 MagicWordFactory to replace MagicWord static members/methods
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
2018-07-30 21:20:43 +03:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$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
2018-05-30 18:05:20 -07:00
Umherirrender
d6e9f55bd2 Updated type and function docs for MagicWord.php
Change-Id: I46ebd315a99b1677ff89ba392c0072b41bbeb36d
2017-10-02 13:52:51 +02:00
Max Semenik
34eec68649 Remove deprecated MagicWord::replaceMultiple()
wfDeprecated since 1.25, not used anywhere.

Change-Id: I09fd362a3d795328ffc12572025702ef9b951378
2017-08-14 02:39:58 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.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
2017-07-22 18:24:09 -07:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
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
2017-02-27 19:23:54 +01:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
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
2017-02-21 18:13:24 +00:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
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
2017-01-31 23:01:54 -05:00
divadsn
e8d13ad1a2 Add a new {{PAGELANGUAGE}} variable for use in wikitext
Returns the language code of the page being parsed.

Bug: T59603
Change-Id: I229edd6251cf1120b3395d1811dbb9d96d9cd8ee
2017-01-07 02:03:53 +00:00
Amir Sarabadani
d56829dca8 Clean up array() syntax from docs, part VI
Change-Id: Ib0eea494e2065c7ab356dc45fd174544a9c1c942
2016-09-12 14:36:37 +04:30
addshore
f0a28890a0 Add access modifiers to MagicWord.php
Change-Id: I3588d9d2c17203ec3ff11736cd6ce84f687677a5
2016-03-01 10:56:04 +00:00
addshore
26cd337c2e Move MagicWordArray class to own file
Change-Id: I9ba602da77f1c8d4270d8ae10d03e82a3197e5b1
2016-03-01 10:49:29 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
Gergő Tisza
a2607aca6b Log warnings on on preg_* failures in MagicWordArray::matchAndRemove()
Softer version of I3840a56adc0a6e50963b930051892491f8e90245.

Bug: T115514
Change-Id: Idb297a31b17928a0151476879294eedfbec0d744
2015-10-29 18:36:23 -07:00
Gergő Tisza
1b39760a3a Revert throwing exceptions on preg_* failures
This reverts I3840a56adc0a6e50963b930051892491f8e90245 which
threw exceptions on broken UTF-8 in $text.

Bug: T115514
Bug: T117066
Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362
2015-10-29 14:52:44 -07:00
Gergő Tisza
ef7760a50d Include preg_last_error() in error message when preg_* fails
Bug: T115514
Bug: T117066
Change-Id: I1d13f8542a4cf11c8e87cd4f6a983fa852dfdf1e
2015-10-29 14:00:37 -07:00
Kunal Mehta
6627978c77 Throw Exceptions on preg_* failures in MagicWordArray::matchAndRemove()
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
2015-10-23 16:24:42 +00:00
umherirrender
2a87697894 Fix use of preg_match_all in MagicWord.php
Init variable before use
Check return value to avoid notice on failures

Change-Id: I5cecae32f7672d748706c7a72bf01e9aee65e6d4
2015-09-10 21:43:46 +02:00
jeroendedauw
a7ab5c8259 Remove unused private field in MagicWordArray
Change-Id: Ib7a0c2834314e9c8db442956230d389e51dbb256
2015-09-10 19:16:17 +00:00
jenkins-bot
9d4029a25c Merge "Remove obvious function-level profiling" 2015-01-07 19:27:45 +00:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
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
2015-01-07 11:14:24 -08:00
Evan McIntire
e6c87b54a7 Marked replaceMultiple() as deprecated
MagicWord::replaceMultiple() is completely unused in both core and
all extensions on gerrit, so it is being marked as deprecated.

Change-Id: I6289a36351a2cbc47a0cad237cc985e5c3136773
2015-01-07 19:07:11 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Chad Horohoe
90d90dad6e Remove hitcounters and associated code
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
2014-10-20 13:01:55 -07:00
umherirrender
7c6a25856c Add missing @return to function docs
Change-Id: I45b9d02f94ecc58372268ec5e6a0b572a0b7e2a9
2014-08-23 23:14:57 +02:00
Jackmcbarn
c313a75c80 Support {{!}} as a magic word
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
2014-06-26 14:56:04 -07:00
Bartosz Dziewoński
a5d145ae3c MagicWord: Fix an indent
Change-Id: I3640fb7a783a68c43a1249b87ef04e587dd0cfd5
2014-05-23 23:24:13 +02:00
Siebrand Mazeland
3f0a2a94c9 Make phpcs-strict pass on includes/ (6/~10)
Change-Id: I566183b5d660a55bb3b2aa7186aaed5355ead2c6
2014-05-12 16:46:52 +02:00
Siebrand Mazeland
c914246666 Fix return type documentation for getCacheTTL()
Change-Id: I57e85351503897f8f8febb2fb49942a2ddd251e6
2014-05-10 20:27:35 +02:00
umherirrender
a3983418d5 Fixed some @params documentation (includes/*)
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
2014-04-22 13:07:02 +02:00
umherirrender
23fab68274 Fix spacing after @param and friends in comments
Searched for:
\@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,}

Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
2014-04-05 20:02:29 +00:00
umherirrender
cf5cb9b79a Raw option of parser functions should match complete word
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
2014-01-12 22:25:33 +00:00
Jackmcbarn
073c4bf16f Add CASCADINGSOURCES parser function
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
2014-01-04 12:08:45 -05:00
Kevin Israel
b9f291e8cd Make MagicWordArray compatible with PCRE 8.34+
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
2013-12-31 05:28:23 +00:00
umherirrender
35065c9db5 Added {{REVISIONSIZE}} variable to get the current size of a revision.
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
2013-09-21 03:49:35 +01:00
MatmaRex
eb542c80c6 MagicWord: Remove some commented-out code
Change-Id: I62014cd09b4033be0c958da2527911368fff141a
2013-07-01 00:55:41 +02:00
umherirrender
15ff79312d Fixed spacing and removed unneeded parenthesis
Added spaces after/before parenthesis
Removed unneeded parenthesis around some statements
Broke a long line

Change-Id: I7fbe129f7bbf524dd0598ece2a9708643f08453b
2013-05-17 16:12:08 +00:00
blotmandroid
d197fbd349 Introducing a new variable {{ROOTPAGENAME}}
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
2013-04-24 02:13:25 +05:30
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00