Commit graph

24 commits

Author SHA1 Message Date
Adam Wight 7b32bcefb4 Add suggested values parameter
Parameters may include a `suggestedvalues` property, which is rendered
in the UI for some parameter types.

TemplateData editor UI elements are implemented behind the
TemplateDataSuggestedValuesEditor feature flag.

Bug: T271897
Change-Id: I14012c79b3fa0d48c58fd8999584cc03ec03575e
2021-04-09 12:05:37 +02:00
Adam Wight d63a375fac Finalize event platform migration
Bug: T275011
Bug: T275012
Change-Id: I51a3c3b6b3943db651807fbb2c0eb17c8c51440f
2021-02-24 16:52:55 +01:00
Thiemo Kreuz 6129f5d589 Don't validate <templatedata> tags on non-wikitext pages
I tested this locally, and indeed: Try to edit for example your
own page http://en.wikipedia.org/wiki/Special:MyPage/common.js
Try to paste and save this:

 var notWikitext = '<templatedata>{</templatedata>';

The page fails to save. (You might not see the error message
because of T258790#6751678.)

But this is not even wikitext. The <templatedata> string is
meaningless and does not trigger any TemplateData code when
the page is parsed and saved. Still there is an additional (!)
parser run that processes every page with the wikitext parser,
no matter what the actual content model is.

This does not only cause strange stack traces (see T272231),
it's most probably a massive performance bottleneck. Luckily
the majority of pages on the Wikimedia cluster is wikitext
anyway.

Bug: T272231
Change-Id: I2efcadc9bae6ecb37314f6d45c0c520abfbb85a0
2021-02-19 15:10:28 +01: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
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 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
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
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
Subramanya Sastry 956367fb90 Implement ParsoidFetchTemplateData hook for Parsoid/PHP
* This hook supports functionality that Parsoid/JS used the MW API for.

  Parsoid's html2wt code requests templatedata for titles one
  at a time currently and so this hook also supports lookups one
  title at a time.

  This initial implementation is good enough for initial Parsoid/PHP
  deployment.

* As part of later performance optimization, we should figure out if
  we want to fetch templatedata for all templates in batch mode and
  work out the details (selser doesn't touch all templates, for one).

  The hook does accept an array of titles, but it looks them up
  serially in a simple for-loop.

  Separately, we need to resolve if this is better architected as
  a lookup service vs. a hook as it is now (see discussion on gerrit).

* Tested locally on my local wiki.

Bug: T238954
Change-Id: I01fb6a9f334ca37a703be497524180f87fb8bbf7
2019-11-25 11:09:13 -06:00
saper ce13175017 Do not always store template data compressed
Only MySQL can handle blobs in page_props.pp_value

Bug: T203850
Change-Id: Ie20d412d89855e451d48f7656d97fb305b1c4c55
2019-09-30 14:24:39 +02:00
Fomafix 962a84ed82 Preload tablesorter styles by module 'jquery.tablesorter.styles'
This change avoids the flash of missing sorting buttons while loading,
but only with I0b446d18f47428d8c0c4aed78b75de16fe106218 in MediaWiki
core included in MediaWiki 1.33 or higher.

Depends-On: I0b446d18f47428d8c0c4aed78b75de16fe106218
Change-Id: I2c3eeb3a83822798ae0c46fcfea071df706798d7
2019-06-12 07:37:10 +02:00
Ed Sanders 822d0cd345 Rename module editPage→editTemplatePage, create minimal new editPage module
VisualEditorPluginModules loads whenever VE loads, so create a minimal
loader page to check if we are in the template namespace before loading
the rest of the TemplateData init code.

Bug: T208765
Change-Id: Id127eb4a2472a6ce9da7672f9237b182cf6be2eb
2018-11-24 00:14:03 +00:00
Ed Sanders 9a8c807f51 eslint: Introduce wikimedia/qunit ruleset
Change-Id: I3972918c00e69d325c5cb2055d4996a8c07b1034
2018-11-15 23:21:32 +00:00
Timo Tijhof 326558fc77 Don't store templatedata pageprop on doc-subpage
This resolves two issues:
* Database inefficiency (T52512).
* Doc pages showing on Special:PageWithProp.

It also makes progress on (but doesn't fully resolve) T54448,
by not outputting encouraging accidental use of "/doc" by
displaying descriptions and parameter documentations for them
below the suggestions in VisualEditor.

Bug: T52512
Bug: T54448
Change-Id: I99323d7adc5fc072a85ff1d3595f805f537bbb43
2018-10-09 17:46:21 +00:00
Saint Johann c608d204c1 Fix problems with MediaWiki messages and non-displaying icons
Bug: T160252
Change-Id: I997bc0f8c7d99f73c1cc6b4ce46f6bcdc1eee410
2018-09-03 17:14:16 +02:00
Kunal Mehta de96754626 Move PHP classes to includes/
Change-Id: I7f46b6da2995687b3ec1ed95cf6f35c2a40d4f1e
2018-04-24 16:50:31 -07:00
Renamed from TemplateDataHooks.php (Browse further)