Commit graph

203 commits

Author SHA1 Message Date
cenarium
a042808b91 Add magic word for protection expiry
This adds a magic word to get the protection expiry for a page for a
given action.
Usage is {{PROTECTIONEXPIRY:action}}.

Bug: T19354
Change-Id: Ia1a20e313781789480dc082bdc7f585c4f0e28df
2015-12-07 10:02:12 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Amir E. Aharoni
bd30ccd795 Make lines shorter to pass phpcs in some files under includes/parser
This doesn't fix all the files under includes/parser -
some of them deserve their own patches.

Bug: T102614
Change-Id: I2fcbc19ee337e1b7db4635b5e5f324c651b4d144
2015-09-26 18:19:11 +00:00
umherirrender
87c1ca1ac1 Escape return of {{int:}} if message not exists
This avoids returning possible html tags like <var> for {{int:var}}.

Bug: T44914
Change-Id: Ibcba9129d88510e6a84282c774ebe2dbfa548462
2015-07-24 22:02:54 +02:00
Arlo Breault
baddcab658 T105242: U is for urlencode
* Urlencode and extension tags don't play nice. The current behaviour
   is pretty broken. For example,

      {{urlencode:<pre id="one">two</pre>}}

   outputs

       <pre id="one">two</pre>

   which isn't exactly urlencoded.

 * Just drop the unexpanded content; anything more seems unsafe. There's
   precedent for this already in anchorencode.

 * Noticed in the infobox caption for enwiki/%22F%22_Is_for_Fugitive

Change-Id: I0ec5d2fdeb71f762036464f65029afd029e8b4a1
2015-07-08 15:28:21 -07:00
David Chan
f5c88ef8e5 Add {{bidi:}} syntax for directionality-safe arguments
In parallel with jquery.i18n version:
https://github.com/wikimedia/jquery.i18n/pull/76

Bug: T104472
Change-Id: I25afa50ab1e0521bd0b3779cbd16b6c190d72722
2015-07-01 11:06:45 -07:00
Max Semenik
08762b02de Minor cleanups
* Declare undeclared variables
* Kill unused variables
* Fix comments including PHPDoc

Change-Id: I60015f6b6740aa9088bda3745f4dc4e65e29fcb1
2015-04-02 16:22:42 +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
Jackmcbarn
c05b4c9bc4 Re-emit unknown tags from #tag
When #tag is given a tag that it doesn't recognize, re-emit it as a
regular tag instead of giving an error. This allows for it to be used with
transparent tags and HTML tags.

Change-Id: I0ceee8a4fdaf2d3142054a108f445ff06597c31a
2014-12-18 23:06:22 -05:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
umherirrender
91f26d50ee Use Parser::SFH_NO_HASH/SFH_OBJECT_ARGS class const
Instead of the global const
Add hint to Defines, that they should not be used.

Change-Id: I3e1dcf46fe18a97a05e3406c209815adb7e0e083
2014-11-18 21:19:22 +01:00
jenkins-bot
cf93d76c03 Merge "Remove hitcounters and associated code" 2014-10-20 21:12:54 +00: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
Kevin Israel
74cba12de3 CoreParserFunctions::displaytitle(): Use Parser::killMarkers()
... instead of doing something similar to an old version of it.

Change-Id: I78db194291236208843a13b80d322d403774796c
2014-10-20 15:59:51 +00:00
Jackmcbarn
edc9f2acd9 Add parser callback to get a page's current revision
Add Parser::fetchCurrentRevisionOfTitle(). By default, this just calls
Revision::newFromTitle, but a callback can be set in ParserOptions that
will override it. Anything that runs as part of a parse should use this
wherever possible.

Bug: 70495
Change-Id: I521f1f68ad819cf0f37e63240806f10c1cceef9c
2014-09-19 11:59:58 -04:00
Aaron Schulz
1e78807f0d Tweaked cache size in getCachedRevisionObject()
Change-Id: I3b01011f21bf3218f3b5c74430b5d5f9ceaec83e
2014-09-03 23:23:43 +00:00
Aaron Schulz
b728d6920b Made getCachedRevisionObject() use MapCacheLRU
* Previously the cache size was unbounded and leaky
* Also made MapCacheLRU handle null values properly

Change-Id: Ia02258cf051e1ccf11457c758741b8c7922afe89
2014-08-22 18:12:29 +00:00
addshore
61c989cfc0 Fix phpcs issues in parser
This fixes all issues except for:
 - class names
 - line length

Change-Id: Ie91b010d5b3eec49d3b80b6e93b125a901ef43c6
2014-08-12 01:00:15 +00:00
Niklas Laxström
457d732dbf Fix bad reference in method doc
Change-Id: Ic721a869cc25792f2fb3a66803efe48d36c4939c
2014-08-04 11:43:03 +02:00
Jackmcbarn
af66fecb2d Warn when DISPLAYTITLE is used more than once
Implement the same duplicate-warning logic for DISPLAYTITLE that
DEFAULTSORT currently uses, to catch cases where a newer call overrides an
older one.

Bug: 50449
Change-Id: Ibce776d019aab07fb88fbb89afc5340300735405
2014-07-08 23:34:50 -04:00
C. Scott Ananian
fb125de072 Allow HTML5 <rtc> tag (ruby support for East Asian typography).
We currently allow <ruby>, <rt>, <rb>, and <rp> but not the W3C HTML5
<rtc> element.  Fix that.

(Note that <rb> and <rtc> are new additions to HTML5 which currently
appear in the W3C but not the WHATWG version of the HTML5 spec.
Support for these has already been merged in gecko and webkit and
the editor plans to update the WHATWG spec.)

Bug: 67042
Change-Id: I8c0e65d782b6d23057a9723b87323b28e8bf8852
2014-07-02 18:45:14 -04:00
umherirrender
4634b57243 Replace deprecated Title::escapeCanonicalURL call
Change-Id: Icd3e2304d6188babe2d887aa32fc0c398352b7b6
2014-06-27 17:12:37 +02:00
Siebrand Mazeland
dfc7416fbe Various documentation updates for includes/parser/
Change-Id: I16dd3a792cc83f8c80b3652d42c055730f6d177a
2014-05-11 18:18:26 +02:00
Siebrand Mazeland
2527cca6de Fix most CodeSniffer issues in includes/parser/
Remaining are the classes containing underscores and possibly a few other
issues that will be addressed soonish.

Change-Id: Icf56374c71afc134420ebbcfecf12dcb29dc9564
2014-05-11 08:44:52 +00:00
umherirrender
7f9fd63901 Fixed some @params documentation (includes/parser)
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: I49f8f48b521878de7abd9cc40efdeff6cf9a37e0
2014-04-22 01:38:39 +02:00
Thiemo Mättig
2aa67db39d Fix "@param null $param" documentations
... and very few other documentation details that are closely connected
to these mistakes.

Change-Id: I5b2691948e196124c77f0cc04d0ed5a7167cac25
2014-04-09 12:33:55 +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
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
tonythomas01
2f8772135b Check for CoreParserFunction::urlFunction from array to boolean
and return values accordingly to htmlspecialchars()

PHP Warning: htmlspecialchars() expects parameter 1 to be string,
array given in CoreParserFunctions.php on line 212
Checked for the return value of urlFunction in localurle() and fullurle()
function

Bug: 59881
Change-Id: I7ae092f89b9cfbbe91d1883c2182ca5907825ba4
2014-01-30 23:43:38 +05:30
umherirrender
c0d3e85b06 Add Title::hasFragment and use it
Makes checks against the fragment easier to read and all the same.
At the moment some using strval, some use type safe comparsion.

Change-Id: I27d9c3e40e6de6800f4488de167cf06e83c88ce6
2014-01-24 15:42:13 +00:00
umherirrender
d810be838d Remove outdated fixme/todo in CoreParserFunctions.php
Title::getLength is not used and documentation of parameter is there

Change-Id: I50679ff19695a3afedd556e242f27e4172a9774a
2014-01-19 11:13:44 +01:00
Jackmcbarn
b2e20f5d57 Don't always count CASCADINGSOURCES as expensive
When a page's cascading protection sources have already been loaded, don't
count CASCADINGSOURCES as expensive.

Change-Id: Ia9d25790c534414f637f85d6a3fc4f2c1c0de790
2014-01-15 16:13:13 -05:00
jenkins-bot
7c5acbe3f7 Merge "Make PROTECTIONLEVEL count as expensive" 2014-01-15 16:28:11 +00:00
Brad Jorsch
6131a214aa pageid parser function is expensive, make it so
The pageid parser function (not to be confused with the pageid magic
word) hits the database for every title passed, which meets the criteria
for being considered an expensive parser function.

To mitigate this new expensiveness, check for special namespaces,
interwiki titles, and titles in LinkCache before hitting the DB.

Also, record potentially-valid titles in pagelinks so that the page can
be properly purged if the target is created/deleted.

Change-Id: I4fbfc265543f0a64c14dc8a44e1c89cd928a1adb
2014-01-14 15:44:08 -05:00
Jackmcbarn
a87e109e67 Make PROTECTIONLEVEL count as expensive
When protection levels for a page have not previously loaded, make calls
to PROTECTIONLEVEL for that page count as expensive. Also, add new
accessors for the protection information.

Change-Id: Ic088a9f482154d5353ccf580bbe5c359371a8cdd
2014-01-13 15:01:17 -05: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
d0610c0370 Include namespaces in {{CASCADINGSOURCES}} output
Include the namespace of pages in the output of the CASCADINGSOURCES
parser function.

Change-Id: Ie39ecfb52965c36349e601bee092590a147b5a03
2014-01-06 16:53:43 -05: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
Siebrand Mazeland
c9f5a5006f Replace usage of deprecated Title::escapeLocalURL()
Change-Id: I1d630ffe5e900a97e169bf3fdab55d0687a67d3b
2013-12-29 16:22:05 +01:00
Skizzerz
e035a14604 Fix error introduced in Change Ieae80c63e391cfb1af61841a6badd51b87d00cfe
The {{NAMESPACE}} magic word is broken by the above commit, since it uses
the function name "mwnamespace" in order to not conflict with the PHP 5.3
namespace keyword.

Change-Id: I807c9b89c101db289c0ec47593c18b0d1dc2260b
2013-12-27 17:55:31 -06:00
Chad Horohoe
0d7de23b3b Break some long lines
Change-Id: I8c3919c04a3fc468191750af51b8be3f952f464e
2013-12-27 16:01:17 -05:00
Chad Horohoe
8ca3b9dc0d Reduce insane amount of code duplication and long lines
Change-Id: Ieae80c63e391cfb1af61841a6badd51b87d00cfe
2013-12-27 15:57:50 -05:00
Siebrand Mazeland
8d0106d585 Remove last remainig use in core of Title::escapeFullURL()
This was deprecated in MediaWiki 1.19.

Change-Id: I21a46a35e449b81d5999420add91d7664fcf5f1d
2013-12-27 15:01:26 +01:00
umherirrender
2b980a226f The static declaration must come after the visibility declartion
Change-Id: I7f4646a5eb3acc7209b243c82a5a496daf82cf8f
2013-11-23 14:42:32 +01:00
umherirrender
1523621054 Add expensive parser functions {{REVISION*:}}
The magic words REVISIONID, REVISIONUSER and REVISIONTIMESTAMP (with
friends) now exists as parser function to fetch revision information
from another page specified as param to the parser function.

Invalid title or non-existing title will return an empty string.
Requesting revision deleted information will always return an empty
string, because this is for public audience and goes into the parser
cache.

The parser function will register a template link to get updated with
refresh jobs on edit of the remote page. This is the same way, than
the parser function pagesize is working.

When the given param is equal to the current title of the parser, the
parser function will yield the previous versions on preview and on
substitution, that includes empty strings when used on page creation,
but using the values from the current version for page view, including
viewing old revisions.

Bug: 6092
Change-Id: Ib15a4e54c65192ec3caef71fd5dcb93fb6fc444e
2013-10-29 22:02:59 +01:00
Tim Starling
d1bc243f65 Remove all instances of the word "iff"
It's elitist mathematical jargon. In all cases dealt with here, it adds
no additional meaning compared to "if", beyond what was already obvious
from context. Thus, its only purpose is to smugly demonstrate that the
author attended their second-year mathematics classes, at the expense of
causing confusion for everyone who doesn't have such a background.

If you really think you need to convey extra information beyond what
"if" gives you, the English language contains plenty of devices for doing
so, without resorting to neologisms.

Change-Id: Iae21095d02ec2935c10e94f532235c2671c115b1
2013-10-23 10:56:54 -07: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
jenkins-bot
59404fb12e Merge "Call $wgContLang->findVariantLink() in {{PAGESINCATEGORY: }}" 2013-09-05 07:41:39 +00:00
Liangent
970cc1e8e6 Call $wgContLang->findVariantLink() in {{PAGESINCATEGORY: }}
Corrects inconsistent return value for number of pages in a
category when language variants are in use.

Change-Id: I27668ba348c45bc34b264f8771e91e58a9920552
2013-09-05 07:35:23 +00:00
Liangent
0e57adabc3 Disable language conversion for echoed sortkeys in defaultsort errors.
Change-Id: I24ac06687df126b59a3eddeb4ed00b2ca0ee22e9
2013-07-04 20:25:06 +00:00