Commit graph

82 commits

Author SHA1 Message Date
jenkins-bot 39d95be801 Merge "Replace deprecated Language::getFallbacksIncludingSiteLanguage" 2020-12-17 10:50:08 +00:00
WMDE-Fisch b8b1df894f Add tracking for template data presence
This will give results whenever template data is requested e.g. by
VisualEditor or the TemplateWizard.

Bug: T259705
Change-Id: I2a9e864b94b6f8f49ca3adaa46502627ab6b3322
2020-12-16 12:50:44 +01:00
WMDE-Fisch 49bc2e8735 Replace deprecated Language::getFallbacksIncludingSiteLanguage
Change-Id: I24a95ce973169ab3f76abe39ca9780c3bf4ec5a4
2020-12-16 12:07:34 +01:00
WMDE-Fisch 028aaba896 Replace deprecated getNativeData
Change-Id: Icbee3fd7245e81b7c3c49e2aab6607c0a8e61217
2020-12-16 10:36:56 +00:00
WMDE-Fisch ae0dd0e094 Get WikiPageFactory and LanguageNameUtils from services
The bump to 1.36 was overdue because the PageProps are used from
services already.

Change-Id: Ic4b42f58290e15123b281d48be396e8b7e8eeab0
2020-12-15 14:15:47 +01:00
Umherirrender 88f31acbd7 build: Remove unneeded phan suppression
Possibly not needed after core change
I40a305b5e49d67b3f6d7737c0846b93a80b78fa9

Change-Id: Ided42bd763718f0393a874bbadb0b682b4bb9043
2020-12-13 00:20:53 +00:00
libraryupgrader 4d7ffb97a6 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.10.4 → 0.10.5

npm:
* ini: 1.3.5 → 1.3.7
  * https://npmjs.com/advisories/1589

Change-Id: I5f54f5b504df70819338ca17bf2b67af6851f798
2020-12-11 13:35:56 +00:00
Thiemo Kreuz d08a6448e9 Track when (relevant) changes are made to <templatedata> tags
Bug: T267926
Change-Id: I55f72500b7bad7e648238560b516e870bc9130c8
2020-12-07 15:34:13 +01:00
daniel 4478384155 Revert "Add logging for parser cache misses."
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
2020-11-17 21:07:03 +00:00
Cindy Cicalese 45907dc7d4 Make extension data JSON-serializable #2 - write JSON.
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
2020-11-09 19:48:47 +00:00
daniel dd81de53d7 Apply bucketing to query sizes stats
Change-Id: I921e5bec971fac1303b26322bb0898016c251bea
2020-11-03 20:31:01 +01:00
daniel 9a85a1b67e Add logging for parser cache misses.
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
2020-11-02 22:18:38 +01:00
Cindy Cicalese b10862a333 Make extension data JSON-serializable #1 - forward-compat.
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
2020-10-30 12:33:20 -04:00
jenkins-bot 86a6865512 Merge "Fix parameter extraction from wikitext source" 2020-10-06 23:07:23 +00:00
Ammar Abdulhamid 0b03b04dcc Force tag content to string before constructing TemplateDataBlob object
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
2020-09-23 05:35:37 +01:00
Thiemo Kreuz f6de5d3493 Fix parameter extraction from wikitext source
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
2020-09-22 18:27:23 +02:00
jenkins-bot 077cb83cc9 Merge "Add and update soft PHPDoc type hints" 2020-09-21 01:00:27 +00:00
jenkins-bot 6d6ef56ea2 Merge "Prefer Html::rawElement instead of open/closeElement" 2020-09-21 00:53:23 +00:00
Thiemo Kreuz 9f878897cf Turn static variables into private constants
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
2020-09-14 14:17:25 +02:00
Thiemo Kreuz ac0630edd1 Add all missing PHPDoc comments
Change-Id: I4bf77867209e8aef524707b02363ae0ff7ca1f2a
2020-09-09 17:05:54 +02:00
Thiemo Kreuz eeffc4bf38 Prefer Html::rawElement instead of open/closeElement
Html::open/closeElement are hard to read and possibly error
prone. We can easily avoid it in this case here.

Change-Id: I2251cb63e58bc132ced0bb684e3f0e3be35ab1aa
2020-09-09 16:54:59 +02:00
jenkins-bot 6dd0b66fea Merge "Make TemplateDataBlob::normaliseInterfaceText() private" 2020-09-08 22:45:15 +00:00
jenkins-bot 8e56813b6e Merge "Use more canonical (object)[] instead of new stdClass" 2020-09-08 22:45:13 +00:00
jenkins-bot 3319103531 Merge "Make properties in TemplateDataBlob private" 2020-09-08 22:17:40 +00:00
jenkins-bot 81c7cc823e Merge "Make subclass constructors properly call each other" 2020-09-08 22:17:39 +00:00
Thiemo Kreuz f2306a2eab Make properties in TemplateDataBlob private
No subclass is directly using these. They don't need to be
protected. There are getters, if needed.

Change-Id: I27dcb8bee37b9559242451774c52240b490a18af
2020-09-04 15:28:15 +00:00
Thiemo Kreuz a4813c26f3 Add and update soft PHPDoc type hints
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
2020-09-04 06:10:24 +00:00
Thiemo Kreuz 53d6c2fcd9 Make subclass constructors properly call each other
In detail:
* Mark both as protected and make them call each other.
* Avoid duplication.
* Remove unused "null" default value.

Change-Id: I272a68bb3cc0c544ef306b16c2998458c2eb1a2d
2020-09-04 06:09:35 +00:00
Thiemo Kreuz 62c608f172 Add strict type hints in unambiguous places
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
2020-09-03 12:12:19 +02:00
Thiemo Kreuz a2415bb32a Turn static property into private constant
We can do this in PHP now.

Change-Id: I54ae244651134424d5a2b1ce27d685f8165692da
2020-08-26 13:00:26 +02:00
jenkins-bot b442c40255 Merge "Remove obsolete return true and & from hook handlers" 2020-08-20 15:45:21 +00:00
jenkins-bot 4a45fd6cbf Merge "Remove unused variables" 2020-08-20 15:07:00 +00:00
Thiemo Kreuz 1d798c0e43 Remove redundant null check after isset()
isset() already checks if a thing a) exists, and b) is not null.

Change-Id: I5291ee30c8897dda1a5c095e196d5b5477a1877b
2020-08-20 12:20:58 +00:00
Thiemo Kreuz 10971b6124 Make TemplateDataBlob::normaliseInterfaceText() private
Not used anywhere else:
https://codesearch.wmcloud.org/search/?q=normaliseInterfaceText
Doesn't even need to be static, as it is never called from a
non-static context.

Change-Id: I0981392e18cab08fb19501f57d805caf8f57dd4a
2020-08-19 15:40:55 +02:00
Thiemo Kreuz 62ac9da173 Use more canonical (object)[] instead of new stdClass
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
2020-08-19 14:23:29 +02:00
Thiemo Kreuz 7fd1367918 Remove obsolete return true and & from hook handlers
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
2020-08-19 14:14:35 +02:00
Thiemo Kreuz 4a0d7139ca Remove unused variables
Change-Id: I3f307113be730d770af796e91bc28bb149c45ad5
2020-08-19 14:11:02 +02:00
Siddharth VP 512911b92e Make getRawParams() ignore parameters in comments and nowiki tags
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
2020-08-17 00:33:06 +00:00
adham-khatean 55a423a5ba Remove Sortable class from tables that have one row or less
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
2020-06-22 09:13:17 +01:00
libraryupgrader d2cee1239d build: Updating mediawiki/mediawiki-phan-config to 0.10.2
Additional changes:
* Removed phan-taint-check-plugin from extra, now inherited from mediawiki-phan-config.

Change-Id: I1f52b9bd1dbbdf15359d16efd5fc35eaf8b8ea76
2020-06-02 02:54:09 +00:00
Reedy 0deac36b6e Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I92970c67565792e8d2282e9f4c4c02a61ed30dbe
2020-05-20 01:06:40 +01:00
James D. Forrester edf85c08e7 Use QUnitTestModule instead of deprecated ResourceLoaderTestModules
Bug: T232875
Change-Id: I5612a9be65f4d4adf4912645856540dbb04d2b34
2020-05-11 19:45:10 +00:00
C. Scott Ananian e3c95c281f Improve directionality settings for TemplateDataBlob rendering
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
2020-04-09 11:45:24 -07:00
C. Scott Ananian 4dcda73ef7 Remove deprecated Parser::enableOOUI(), take 2
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
2020-04-08 16:10:33 -04:00
C. Scott Ananian 3f270b9ad7 Don't use deprecated Parser::enableOOUI() hook
Follow up to I71be19c1d735fef5b781c68ef7ba47cafc37595d.

Bug: T236809
Change-Id: Ib75f530506bfc9692137b0538f66eb5b511637f0
2020-04-08 13:47:08 -04:00
DannyS712 720aff85b1 PHP coding conventions: reorder doxygen tags
See https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Doxygen_tags

Change-Id: Ied27b09fd717fd469170dc842091732195b4046d
2020-03-26 15:48:33 +00:00
libraryupgrader e3fb9734b1 build: Updating composer dependencies
* jakub-onderka/php-console-highlighter: 0.3.2 → 0.4.0
* mediawiki/minus-x: 0.3.2 → 1.0.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.9.1

Change-Id: Ifdb5afed1ec5114d9e25ebbd81259d77cdc33e13
2020-01-30 12:25:48 +00:00
Timo Tijhof 6f362c6d8a Minor clean up in new ParsoidFetchTemplateData hook
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
2020-01-28 19:14:12 +00:00
libraryupgrader 9a41a95389 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
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
2020-01-14 12:46:52 +00:00
libraryupgrader 1c8f1b14e8 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Additional changes:
* Added .eslintcache to .gitignore.

Change-Id: I96c348782dc892efb80e2fffa898f595fa76c43a
2019-12-28 17:21:07 +00:00