Commit graph

1750 commits

Author SHA1 Message Date
Tim Starling
a6a017cea4 Fix use of non-existent variable Parser::$config
Fix bug from Ib4394f370cb561ccf195338a1c2e9e465dcb3dc3

Add test.

Bug: T208000
Change-Id: Ia81cca1b64afef2af3cb8dff19719a7f0de9d306
2018-10-25 16:27:55 -07:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
jenkins-bot
b3f03fd75e Merge "Inject Config into Parser instead of using globals" 2018-10-17 14:34:31 +00:00
Edward Chernenko
559b0f3e54 Fix warning in doEditSectionLink() caused by not-yet-unstubbed $wgLang
In ParserOutput::getText(), $wgLang can be a StubUserLang object,
which causes a typecheck warning in doEditSectionLink().

Solution is to replace $wgLang with $context->getLanguage(),
which is always a Language object.

Change-Id: I9945e1615c3f1b7ed5c7897b9f67d7ca0450ee50
2018-10-15 23:21:02 +03:00
jenkins-bot
9da7211bc8 Merge "Allow and use type Language instead of string for $lang of doEditSectionLink" 2018-10-11 19:52:13 +00:00
jenkins-bot
bcb2f5b0cd Merge "Drop ParserLimitReport, deprecated in 1.22" 2018-10-11 19:47:10 +00:00
jenkins-bot
b53f299af2 Merge "Revert "Unwrap HTML loaded from parser cache"" 2018-10-11 18:11:55 +00:00
Fomafix
35d1ea57e1 Allow and use type Language instead of string for $lang of doEditSectionLink
Hard-deprecate that the parameters $tooltip and $lang are optional.
Hard-deprecate other types than Language for parameter $lang.

Change-Id: I3ce048e3d0de9a4e96e2aa05d75a4ce41c3ec964
Depends-On: Ibe295e7020e995eea52e319feaf59c635f8bb4dc
2018-10-11 18:16:43 +02:00
James D. Forrester
976c50c21a Drop ParserLimitReport, deprecated in 1.22
Change-Id: I4898d92569bd823f09c12f68fa186e2e139790a7
2018-10-10 16:20:18 -07:00
Gergő Tisza
617dbc4c18 Revert "Unwrap HTML loaded from parser cache"
This reverts commit 1bb5b58eb1.
A month has passed, the workaround for old parser cache entries
should not be needed anymore.

Bug: T203716
Change-Id: I446b47cc6b4c43aaae33675d62086d842b04ddcb
2018-10-09 18:29:20 +00:00
daniel
414215ccac ParserOutput::getCacheTime should stay the same after the first call.
Previously, getCacheTime would default to the current time, potentially
causing the return value to change over subsequent calls. With this change,
the value is determined on the first call, and then remembered for subsequent
calls.

Bug: T205464
Change-Id: If240161c71d523ad5b0d33b9378950e0bebceb6e
2018-10-04 13:08:56 +02:00
Aryeh Gregor
5173d5ee60 Inject Config into Parser instead of using globals
Change-Id: Ib4394f370cb561ccf195338a1c2e9e465dcb3dc3
2018-10-02 21:26:01 +03:00
jenkins-bot
67dc908246 Merge "Preserve whitespace in search index text content" 2018-10-01 18:22:48 +00:00
jenkins-bot
50f6b24ee6 Merge "Parser: Refactor parsing of [[File:...|link=...]] syntax for reusability" 2018-09-26 19:18:34 +00:00
Bartosz Dziewoński
1c9664d18a Parser: Refactor parsing of [[File:...|link=...]] syntax for reusability
Change-Id: I91467297de4b7c532448a4c20b9a0dc8216c7200
2018-09-26 13:36:32 +02:00
jenkins-bot
d96f1c2416 Merge "Hard-deprecate the $wgUseTidy option" 2018-09-20 20:29:00 +00:00
C. Scott Ananian
6f8431c4f5 Hard-deprecate the $wgUseTidy option
This has been soft-deprecated since MW 1.26; this hard-deprecation
sets the stage for future removal of this old cruft.

Bug: T198214
Depends-On: Idf246d05d116f63a73105b50a1929a7721fbe7b9
Change-Id: I2e7d990da1da378eb6e828d4b3c0f5a41791dd92
2018-09-20 11:08:40 -04:00
C. Scott Ananian
327f0f92fa Use wfIsHHVM() instead of a HipHop-specific environment variable
Change-Id: I5bbf3e4f65d9b6a0d7419f67e3931e77e92b7e6c
2018-09-20 09:23:54 -04:00
Umherirrender
a4caa4d0c6 build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
Added spaces around .
Removed empty return statement which are not required
Removed return after phpunit markTestIncomplete,
which is throwing to exit the test, no need for a return

Change-Id: I2c80b965ee52ba09949e70ea9e7adfc58a1d89ce
2018-09-16 15:51:11 +00:00
Erik Bernhardson
0d779c1ac6 Preserve whitespace in search index text content
Certain html tags imply a word break, but our html stripping doesn't
understand that at all. Adjust the html stripping to inject whitespace
for all block level tags (per MDN) along with the <br> element.

Bug: T195389
Change-Id: I9fbfac765ea88628e4f9b2794fb54e1cd0060203
2018-09-14 11:10:35 -07:00
Gergő Tisza
1bb5b58eb1
Unwrap HTML loaded from parser cache
Partially and temporarily reverts I1641b7995 to deal with cached
HTML the same way the old code did.

Bug: T203716
Change-Id: I29846a6513f6b580b429c0bfe6c310ada50b28bb
2018-09-07 18:49:34 +02:00
daniel
465954aa23 Provide new, unsaved revision to PST to fix magic words.
This injects the new, unsaved RevisionRecord object into the Parser used
for Pre-Save Transform, and sets the user and timestamp on that revision,
to allow {{subst:REVISIONUSER}} and {{subst:REVISIONTIMESTAMP}} to function.

Bug: T203583
Change-Id: I31a97d0168ac22346b2dad6b88bf7f6f8a0dd9d0
2018-09-06 18:33:44 +02:00
Brian Wolff
13e5700b23 Use annotations for taint in Parser & ParserOutput.
This replaces the builtin taints that are removed in
Ic1e1983a51c. Additionally, parse will no longer warn about
double escaping - there's many situations where such warnings
are wrong (e.g. Using Html::rawElement()). However this also
means that Parser::parse( wfMessage( 'foo' )->parse() ); will
no longer give a double escaping warning, which is unfortunate.

Bug: T202380
Change-Id: Ia52d37411beb62b112c6ff102438063c3d750769
2018-08-31 15:55:44 +00:00
jenkins-bot
a76baefe8e Merge "Make HTML generation in RenderedRevision optional" 2018-08-31 11:38:15 +00:00
jenkins-bot
a3357744c3 Merge "[MCR] Introduce RevisionRenderer" 2018-08-31 11:25:15 +00:00
daniel
d8c409dd16 Make HTML generation in RenderedRevision optional
This allows optimization for situations in which a caller
needs the meta-data of a ParserOutput, and the respective
ContentHandler can provide that meta-data without generating
HTML output.

Bug: T194048
Change-Id: I786d294d18a6a2e3cea61577313e21b578c44f1e
2018-08-31 10:48:41 +00:00
Kunal Mehta
eb7150b029 Set @param-taint for Parser::internalParse()
This is not strictly accurate, because Parser::internalParse() actually
returns half-parsed HTML, which is not safe for output. But it is safe for
output from a parser tag.

Maybe phan-taint-check plugin needs to learn about half-parsed HTML as an
extra taint type, and make that an acceptable thing for parser tags to return,
but not other things.

But this fixes the failures for the Listings extension, so I think it's
worthwhile in the meantime.

Change-Id: Idf87f5c3dcf81dd210de73a4ff15e3b1aabd9f89
2018-08-30 21:46:10 -07:00
daniel
e9f71517f7 [MCR] Introduce RevisionRenderer
RevisionRenderer is the MCR replacement for Content::getParserOutput,
as outlined in <https://www.mediawiki.org/wiki/User:Daniel_Kinzler_(WMDE)/MCR-PageUpdater>.

Note: This change also introduces quite a bit of code for
merging ParserOutput objects.

Bug: T194048
Change-Id: I871978bf79f67c9e7954fb3fc8528d6e365f2cc1
2018-08-30 19:15:12 +02:00
jenkins-bot
ba6c827485 Merge "Apply content wrapping in ParserOutput::getText()" 2018-08-29 16:25:22 +00:00
daniel
0dc7ba02b4 Apply content wrapping in ParserOutput::getText()
Instead of applying wrapping the the parser and unwrapping in
ParserOutput::getText(), turn this around and apply wrapping in getText(),
and only if desired.

This avoids search&replace logic for unwrapping, and it also makes it a lot
easier to merge the output of multiple slots for MCR output.

This changes behavior in two hopefully irrelevant ways:
1) the limit report comments will be inside the wrapper div, instead of
following it.
2) if HTML with a wrapper div is explicitly injected into a ParserOutput
object, it will not be possible to unwrap the text.

Bug: T174035
Change-Id: I1641b7995af9bd297f1acd610d583fbf874f34e0
2018-08-29 16:46:25 +02:00
jenkins-bot
e548e0f35c Merge "Make interwiki transclusion use the WAN cache" 2018-08-27 21:17:04 +00:00
Aaron Schulz
6504e23074 Make interwiki transclusion use the WAN cache
This means that now:
* Entries actually get deleted when expired
* The transclusion cache is shared across wikis
* Large blobs that do not fit in cache no longer cause DB errors
* DB writes are not triggered on GET requests
* Keys are hashed and no longer need to be so restrictive

Also, add a "check key" based purge system and process cache the
text/html values similar to how regular revision text is cached.

Bug: T189702
Change-Id: I8ac12b53c02bb26857175dd5a4af29d49e03dc33
2018-08-27 19:32:04 +00:00
Kunal Mehta
2912873a61 parser: Simplify code for {{#int:}} if the message doesn't exist
Ever since 184658eb32, the output of a non-existing message will be
HTML safe, regardless of output format, so we can treat non-existing messages
exactly the same as messages that do exist.

The pre-existing "int keyword - non-existing message" parser test verifies
that no change in output has ocurred in this patch.

Change-Id: I0e32be14f1b420d7f222ac3c76e1cc266f912b69
2018-08-25 01:20:43 -07:00
Kunal Mehta
2852255186 Inject SpecialPageFactory into Parser
Change-Id: I6a6a94cbdafdc724ce02408cd9e744e7b3eda92b
2018-08-17 12:03:13 -07:00
Aryeh Gregor
e68fdb4065 Mass conversion to SpecialPageFactory service
Change-Id: Ia6e1e819ec6cbe8bf75b820109f51d47863e31fc
2018-08-17 12:03:12 -07:00
Kunal Mehta
b7b8f214bb Parser: Call firstCallInit() in getTags/getFunctionHooks
So callers don't need to do this manually. Pointed out by Tim in T201799.

Depends-On: Ia6c36d5a650095e35093bf47e275e081e89b3daf
Change-Id: Ida62767f3ca53f99609cae01d3a20051bb92ccab
2018-08-14 14:16:42 -07:00
Kunal Mehta
e8370d6977 Parser: Add accessors needed by CodeMirror
Change-Id: Ia2d98baf6caed2cd779cb00aceba5785cf13d633
2018-08-13 22:44:48 -07:00
Fomafix
73f94fd8cd Add type hint Language where possible
Also use ?? instead of ?: to check for null.

Change-Id: I058b61d7e06cdefecdafa82f60109cc386e2a809
2018-08-12 10:20:11 +02:00
jenkins-bot
fe25fde55b Merge "Add type hint for ParserOutput" 2018-08-12 07:03:19 +00:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Aryeh Gregor
03bf3273e2 Update LinkHolderArray to use ContentLanguage
Bug: T200246
Change-Id: Ic954f7752fda8e2a1f34a64b85cce27774014666
2018-08-11 07:26:21 +00:00
Aryeh Gregor
81c60356ff Update CoreParserFunctions to use ContentLanguage
Bug: T200246
Change-Id: I4e32195b46967d70e69eeccf3ecd1887e8ae7da8
2018-08-11 07:25:59 +00:00
Aryeh Gregor
bca6085920 Use ParserFactory in a bunch of places
I wasn't sure how to convert the rest of the occurrences in core (there
are a significant number).

Bug: T200881
Change-Id: I114bba946cd3ea8a293121e275588c3c4d174f94
2018-08-11 00:16:17 -06:00
Aryeh Gregor
62515f7b15 Introduce ParserFactory service
Bug: T200881
Change-Id: I257e78200983cb10afb76de1f07dd1b9d531c52a
2018-08-11 00:15:52 -06:00
jenkins-bot
8e7f352610 Merge "Update Parser to use ContentLanguage" 2018-08-03 04:52:25 +00:00
Aryeh Gregor
c2f29a2efc Update Parser to use ContentLanguage
Bug: T200246
Change-Id: Ie54677706ec175189c3ff52342a9d8ac2f5d90d8
2018-08-03 04:29:39 +00:00
Kunal Mehta
612f6e5690 Document Parser::$mFirstCall
And don't bother checking its value in clearState(), since firstCallInit()
will do that anyways.

Change-Id: Ibc5e809daa614e99be91d65a363de4f697e6afa5
2018-08-02 01:57:53 -07:00
Aryeh Gregor
5a16d92e04 Update MagicWordArray to use MagicWordFactory
Bug: T200247
Change-Id: Ie5a60b81382d7299beadc691fe4d27e931ebe0ed
2018-07-31 21:40:21 +03:00
Aryeh Gregor
72ab013be0 Update CoreParserFunctions to use MagicWordFactory
Bug: T200247
Change-Id: I122d8acf601581b18756a5b8d65e50953b28c21d
2018-07-31 15:36:57 +03:00
jenkins-bot
0ad38c3a44 Merge "Update Parser to use MagicWordFactory" 2018-07-31 05:37:54 +00:00