This will give results whenever template data is requested e.g. by
VisualEditor or the TemplateWizard.
Bug: T259705
Change-Id: I2a9e864b94b6f8f49ca3adaa46502627ab6b3322
We got the info we wanted, the statistics gathering is now just
causing extra ParserCache lookups.
This reverts commit dd81de53d7.
This reverts commit 9a85a1b67e.
Bug: T266200
Change-Id: I830797e287118fbde07e0e22e1304b30ee9f67e5
Switching ParserCache to JSON serialization requires
extensions to stop writing non-JSON-serializable objects
into ParserOutput::setExtensionData.
This should be deployed at least 1 train after dependencies.
Bug: T266252
Change-Id: I24dfbcff47b6a317d9928fda8c70da64f2d6bc82
This should help us decide whether it would be OK to
rely on the ParserCache to store parsed TemplateData.
This patch should be reverted once we have collected
the desired data.
Bug: T266200
Change-Id: I0631806145d46e4a5e7c177797b8fdfe7a152076
Transitioning of ParserCache to JSON serialization will add
a requirement that all the extension data is JSON-serializable.
This is the first step in transition - making it forward-compatible.
Bug: T266252
Change-Id: If1c9d9bb5b0039df80a9d9b30c247206d8844c0a
This null was being forced to string by PHP before strict typing in I9a20335
This is a rare error as self-closing tag is not allowed as far as
I can see and will emit proper syntax error after this change; but
it should not raise fatal exception
Bug: T263605
Change-Id: I1d9f674fb92d1f1cf70b57e820f8fc3312be9cc8
This fixes a series of issues:
* The JS implementation had a trim() in one place that was
missing in PHP.
* The actual parameter name in the paramNames/$params array was
trimmed, but the "normalized" name (this is only for duplicate
detection) was not trimmed.
* It was possible for an empty parameter to show up.
This resulted in very strange behavior, e.g. {{{ 1}}}{{{1 }}}
was detected as "1" and "10" (?), i.e. it would try to renumber
the duplicate in a strange way (string "1" plus a counter that
starts with 0).
Change-Id: I0a6371f3633b03b5b21809ecd06ea4c72d7d914d
These are not really variables. They are never modified, and not
meant to be modified. Using "static" was a common workaround
when we had no private constants in PHP.
Change-Id: Ie1234ce8833986431be95f8537282fa174978063
Html::open/closeElement are hard to read and possibly error
prone. We can easily avoid it in this case here.
Change-Id: I2251cb63e58bc132ced0bb684e3f0e3be35ab1aa
No subclass is directly using these. They don't need to be
protected. There are getters, if needed.
Change-Id: I27dcb8bee37b9559242451774c52240b490a18af
In detail:
* Callers don't need to know that the return value can be a
TemplateDataCompressedBlob. All relevant stuff is declared in
the base class.
* It's not relevant which internal method returned the status.
It's just the status of the object after it was constructed.
* "stdClass" is more specific. "object" includes more stuff
which can't be returned here.
* Avoid duplication and use @inheritDoc instead.
Change-Id: I68878a5b26ecd566fbea88b513ee697b45769659
In detail:
* Mark both as protected and make them call each other.
* Avoid duplication.
* Remove unused "null" default value.
Change-Id: I272a68bb3cc0c544ef306b16c2998458c2eb1a2d
Notes:
* In PHP, when a function parameter does have a strict type,
all it does is forcefully casting the value to this type. It
doesn't cause warnings.
* Violating a strict return type causes a warning.
* I'm intentionally not touching places where the result from
json_decode() is passed through. In theory this could be
anything. Let's update these later, after more refactoring
is done.
Change-Id: I9a203356f70cf9edd434f7dc4ca130c2b7605ab4
Both styles create the exact same object. Casting an array to an
object creates an stdClass object as well. The main benefit of this
syntax is that there is much less repetition. Everything is one
token instead of individual lines, where each line might contain a
typo.
Change-Id: I8fb09e9d33e5a1d91d4b32a71f658b31c629987b
In detail:
* Don't pass the Parser by reference. Hook handlers don't need to
replace the object with another one, and shouldn't.
* Use __CLASS__ instead of repeating the class name.
* Returning true from a hook is meaningless and indistinguishable
from the default.
Change-Id: Iac60f7f4946eb78cfb3b579fcdb1cab8bdcac7cd
This is used by the includeMissingTitles option of API action=templatedata.
Parameter syntax existing within nowiki tags or comments will not be valid
for the template.
Bug: T237195
Change-Id: Ibbfa3e21488f2a37fc494862e929baf50607d4c9
Removing the sorting arrows from tables that have one row or less in
templates. By using variable $sorting that changes according to the
coung of elements in the array $data->params, to determine whether the
table should have "sortable" class or not.
Bug: T126150
Change-Id: I414c2375d4eb4da5d78f92f6b4e99b55e314ce4d
Additional changes:
* Removed phan-taint-check-plugin from extra, now inherited from mediawiki-phan-config.
Change-Id: I1f52b9bd1dbbdf15359d16efd5fc35eaf8b8ea76
The <templatedata> extension tag wants to render itself into HTML
before an OutputPage has been set up. Unfortunately, this meant that
we needed to hack in a call to OutputPage::setupOOUI() with default
theme and directionality, regardless of whether those were correct.
Slightly improve matters by using the directionality of the user
language object, but this codepath really needs to be rethought.
Follow up to Ie3f37b8b972dc6e89e3cd334672954d3632c1b20; see also
the discussion in T101666.
Change-Id: I6ae99ea6bd8b6ee21b8ed8b06dc4e9e324050ab7
This adds a missing call to OutputPage::setupOOUI(), to fix a code path
where `<templatedata>` is expanded via API call (eg, during Parsoid
rendering) and an OOUI theme has not been set up. This hacky workaround
is pretty bogus, since the output will not have the proper user skin
or directionality, but it avoids a crash (and duplicates the previous
behavior, without using the deprecated method).
Change-Id: Ie3f37b8b972dc6e89e3cd334672954d3632c1b20
Follows-up 956367fb90.
* Fix typo.
* Remove <del>footgun</del><ins>dangerous return value</ins>
from this unabortable hook.
* Document the weird PageProps workaround.
This should be fixed in core.
Change-Id: I6b22e9c2112039e5703e6a62252f1909b15c8887
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.
Change-Id: I8846de470461b4887dbc1e33653c8cdec8839366