Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.
Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
We are deprecating dynamic properties on the Parser object, but as a
first step we're making them *actual* properties, so that we can draw
a line in the sand against adding new dynamic properties. In a follow
up we'll actually remove this property from the
LabeledSectionTransclusion extension.
An entry in RELEASE-NOTES-1.42 was already added in
Id3dbc99d92f2769d4e5c95293cf1a277b98ddd3b.
Bug: T362693
Bug: T343227
Bug: T362692
Followup-To: I701a27459704839f9f996a171b6982ed17cdd00b
Change-Id: I3a992f4d601135b6327d941a1852e861d1e82d78
We are deprecating dynamic properties on the Parser object, but as a first
step we're making them *actual* properties, so that we can draw a line in
the sand against adding new dynamic properties. In a follow up we'll
actually remove this property from the ProofreadPage extension.
Also add an entry to RELEASE-NOTES-1.42, which
Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c forgot to include.
Bug: T362664
Bug: T343227
Followup-To: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
Change-Id: Id3dbc99d92f2769d4e5c95293cf1a277b98ddd3b
Hack in declared public properties to work around T343229 (use in
Scribunto), T343230 (use in Cite), T343226 (use in TemplateStyles),
T203531 (use in Variables), T203532 (use in Arrays), T203563 (use
in Loops), T359887 (use in HashTables) and T357838 (use in parser
tests) for now, but we can draw a line in the sand and not allow
any further use of this pattern.
Bug: T343227
Depends-On: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
Change-Id: I701a27459704839f9f996a171b6982ed17cdd00b
Remove dead code left over from the removal of the
BeforeParserFetchTemplateAndtitle (sic) hook in
20c5632c4e.
While we're at it, add test cases for statelessFetchTemplate and
improve coverage.
Followup-To: Ifecd4108eb02ebccc0c7bc4ec432036da08ffe53
Followup-To: Idf1fd12cc61ca30867dc9f8aeb1701fe035fc5ff
Change-Id: I135f5234e7be015a2781d6cb8d23b3143b618c5a
This follows up on I5e87b33a956e296cdaf671fa99c9555944b73479 and makes
(invisible) language links consistent with how we handle (invisible)
category links.
Bug: T359886
Followup-To: I5e87b33a956e296cdaf671fa99c9555944b73479
Change-Id: I3e5567a91b47e0b04da928450644f3f475aaf51b
This follows up on a long series of tweaks to whitespace handling around
[[Category]] links (T2087, T87753, T174639) which aimed to simplify and
make intelligible the whitespace handling around category links without
allowing categories to break lists or paragraphs in which they are found.
Removing newlines but not other whitespace on the left-hand side of
category links should preserve the valuable features of T2087 et al
while still ensuring that the following all render equivalently:
ABC [[Category:Foo]]DEF
ABC[[Category:Foo]] DEF
ABC [[Category:Foo]] DEF
Added parser test to document the new behavior; it's worth noting
that although there were plenty of tests documenting the expected
interaction of category links and newlines, there were previously
no tests covering the interaction of non-newline whitespace and
category links; the one test which needed to be altered added
non-semantic whitespace (ie, extra whitespace to the test output
which did not affect the way the HTML would display).
This patch brings the legacy parser into parity which Parsoid parsing
of category links.
Bug: T359886
Change-Id: I5e87b33a956e296cdaf671fa99c9555944b73479
This ensures uniform treatment of all places that call `addCategory`
without duplicating the `defaultsort` code; it also ensures that the
effect of the {{DEFAULTSORT}} parser function is independent of page
position.
Bug: T40435
Bug: T353530
Change-Id: I4480a6d59e766fa4eddc9ec9117c58b66771bb47
ParserOutput::getText() is not a simple getter, but does
transformations on the "text" of the ParserOutput; the simple getter
is named ::getRawText().
To maintain consistency, rename ParserOutput::setText() to
::setRawText() and the property name ParserOutput::$mText to
::$mRawText so future readers are not confused.
The JSON property name as it appears in the serialized ParserCache
is left as 'Text' so that we don't have any forward- or backward-
rollback issues.
Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
[Previously attempted in de0646843a,
reverted in e72e1cd16368346b66853f68e2d13f9b416d5a11.]
Previously, Parser.php used Linker::makeHeadline() in order to
generate the `<h2><span class="mw-headline" id="...">...</span></h2>`
markup for section headings, and this was saved in the parser cache.
Now it generates heading tags with placeholder attributes like
`<h2 data-mw-...="..." ...>...</h2>`, and they are replaced in a
post-cache transform to generate the final heading markup, similarly
to how section edit links already worked.
The purpose of these changes is to allow changing the final markup
depending on skin options without splitting the parser cache (T13555).
Deployment and undeployment safety:
* The new post-cache transform has been already added in commit
Ibce512b3c4a52f74b2d2124f0159e306f2689ea5 for forward-compatibility
(so that if this patch is reverted, new parser cache entries
will still be shown correctly).
Implementation notes:
* There are many ways to keep the temporary information other than
`data-mw-...` attributes, but this way is the easiest to handle
in a post-cache transform (everything is on the DOM node we want
to modify), is compatible with other heading-enhancing code in
DiscussionTools and MobileFrontend, and remains human-readable
if the post-cache transform doesn't run.
* Sadly this code can't be reused to add section heading markup and
section edit links to Parsoid (T269630), because it lacks some of
the necessary metadata, and exposes the rest in ways that are
trickier to handle in a post-cache transform (on other DOM nodes
or outside the document).
Depends-On: If85f89c40834618f23dc0ace2e599efb3b6d5ed4
Bug: T13555
Change-Id: If04d72f427ec3c3730e757cbb3ade8840c09f7d3
Paser::getExternalLinkRel() is defined to return `null` if there's
no attribute to add, but then ParserOptions::getExternalLinkTarget()
may try to append to it and external users might try to actually pass
the $attribs to (eg) Xml::element() and become unhappy if the value
is `null`.
Bug: T357668
Followup-To: Ifec733a923f193b72eaba9a1e604ad4e56c0aef2
Change-Id: I907c22ef070616d81b9a50b0e807a7b8f78b59b5
Previously, Parser.php used Linker::makeHeadline() in order to
generate the `<h2><span class="mw-headline" id="...">...</span></h2>`
markup for section headings, and this was saved in the parser cache.
Now it generates heading tags with placeholder attributes like
`<h2 data-mw-...="..." ...>...</h2>`, and they are replaced in a
post-cache transform to generate the final heading markup, similarly
to how section edit links already worked.
The purpose of these changes is to allow changing the final markup
depending on skin options without splitting the parser cache (T13555).
Deployment and undeployment safety:
* The new post-cache transform has been already added in commit
Ibce512b3c4a52f74b2d2124f0159e306f2689ea5 for forward-compatibility
(so that if this patch is reverted, new parser cache entries
will still be shown correctly).
Implementation notes:
* There are many ways to keep the temporary information other than
`data-mw-...` attributes, but this way is the easiest to handle
in a post-cache transform (everything is on the DOM node we want
to modify), is compatible with other heading-enhancing code in
DiscussionTools and MobileFrontend, and remains human-readable
if the post-cache transform doesn't run.
* Sadly this code can't be reused to add section heading markup and
section edit links to Parsoid (T269630), because it lacks some of
the necessary metadata, and exposes the rest in ways that are
trickier to handle in a post-cache transform (on other DOM nodes
or outside the document).
Bug: T13555
Change-Id: I4eae18d9d16f54391daba0de82ad05e50f07f9eb
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
* Fake exceptions triggered to give Monolog a backtrace are for
some reason "traditionally" RuntimeExceptions, instead, so we
continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.
Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
Parser::braceSubstitution is only called from PPFrame_Hash::expand with
the result of PPNode_Hash_Tree::splitRawTemplate which always sets
'parts' to a PPNode_Hash_Array
Parser::argSubstitution is similarly called without the unnecessary null
check..
The comment was introduced in e002df9 and, although true, even then
the ternary may have been made redundant by a previous refactor.
Change-Id: Ia1c5b8570c65c8e174c723dbd292e11c3a72f54d
Broadened the argument type to allow passing LinkTarget to:
* ParserOutput::addCategory()
* ParserOutput::addLanguageLink()
* ParserOutput::addLink()
* ParserOutput::addImage()
* ParserOutput::addTemplate()
This allows for a tighter interface with Parsoid's
ContentMetadataCollector class and avoids errors caused by passing the
wrong form of string title ("text" with spaces versus "dbkey" with
underscores).
There are a few performance problems remaining after this patch, which
only apply to use by Parsoid (not the legacy parser):
1. ::addLink() does inefficient db requests to fetch the page id for
each link if the optional $id parameter is not passed. These lookups
should be deferred and a LinkBatch used. (The legacy parser always
passes $id.)
2. ::addTemplate() similarly requires $page_id (and $rev_id) to be
passed, so is not currently usable by Parsoid.
3. ::addLanguageLink() uses Title::getFullText() which is not present
in LinkTarget and is currently implemented as a full Title lookup.
This is not an issue for the legacy parser, because it already has a
Title object so the lookup is a no-op, but could be improved for
Parsoid's use.
Bug: T296023
Change-Id: If21ec8563c8a619bdde7c0cb6534bb9009480a21