Commit graph

1178 commits

Author SHA1 Message Date
Ammarpad
e8d2f182e6 ParserTestRunner: Remove unused property $dbClone
Also fix type doc of $fileBackendName.

Change-Id: Ifac11a89c0a4bf8c8c0c6219d2751813cd52b3ea
2022-03-16 16:42:09 +00:00
Umherirrender
bbcf9f7539 Call Maintenance::readconsole statically and fix documentation
Change-Id: Ib33ee8158ee62f8699241c55bd4f43599df9c80f
2022-03-14 21:15:35 +00:00
C. Scott Ananian
0955046ca5 Ensure that ToC is converted into the proper target language
This patch exports the necessary information from the Parser into the
ParserOutput to ensure that the Table of Contents can be properly
language-converted: both ensuring that the target language is correct
(in cases where it differs from the content language) and that various
conversion-suppression mechanisms are functional.  When the
ParserCache does not (yet) have the new properties from Parser, the
behavior is unchanged from before (the content language is used, and
its "preferred variant").

This is a follow up to the "quick fix" deployed in
Ic14b3a49a8ee7ed600485d4f8a363a206035a847 to fix an UBN regression.

Parser tests have also been added to verify that ToC conversion
is correctly done (T299973).

Task T303329 has been opened to (eventually) rename the
'core:target-lang' and 'core:target-lang-variant' properties added to
the ParserOutput in this patch.

Bug: T303235
Bug: T295187
Bug: T299973
Followup-To: Ic14b3a49a8ee7ed600485d4f8a363a206035a847
Followup-To: Ib273f88531c340b561072ee9f616aa60725091e6
Change-Id: Ie0f1d7b6daffc8ff47228f6f086a257518f72717
2022-03-09 00:08:57 -05:00
Arlo Breault
4f22d39828 Fix parserTest name
Follow up to I206f1ccbfee1a601f3e5a4b52cb6acb5a6fbf113

Change-Id: I684e140b9a8d907f72f8e45ba2d7402dcb9d102d
2022-03-01 17:56:08 -05:00
Arlo Breault
1f381ce2cf Sync up with Parsoid parserTests files
This now aligns with Parsoid commit 3326011bc6ac9539eb197a22a22497347a4b2e35

Change-Id: Ifda86614572455d51e1855e5336c9ee613f842fd
2022-03-01 17:28:21 -05:00
jenkins-bot
f1ba4939b8 Merge "Add mw-file-description class on links to the file description page" 2022-03-01 22:14:39 +00:00
Arlo Breault
350721cc2c Add mw-file-description class on links to the file description page
Matches Parsoid output.

Bug: T292657
Depends-On: Iccee2dcbc7b06d80bcb4e026eedc11042585550b
Change-Id: I206f1ccbfee1a601f3e5a4b52cb6acb5a6fbf113
2022-03-01 15:53:05 -05:00
jenkins-bot
e4a3b0d65a Merge "tests: Change use of AtEase to at operator" 2022-02-25 16:40:25 +00:00
jenkins-bot
52c19e6662 Merge "In parserTests.php, load test extension classes" 2022-02-25 08:03:27 +00:00
Tim Starling
b5b3dcfe01 In parserTests.php, load test extension classes
In parserTests.php, instruct ExtensionRegistry to load test classes,
since I recently moved some TimedMediaHandler test classes from
AutoloadClasses to TestAutoloadClasses for preload support, which
broke parserTests.php.

Change-Id: Ibc620865b1ce0f3ae95340477005b977f0509a2b
2022-02-25 12:21:45 +11:00
Timo Tijhof
128debb64b tests: Change use of AtEase to at operator
Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359.

Per T253461, not mass-changing source code, but the use of the native
error silencing operator (@) is especially useful in tests because:

1. It requires any/all statements to be explicitly marked. The
   suppressWarnings/restoreWarnings sections encourage developers to
   be "lazy" and thus encapsulate more than needed if there are multiple
   ones near each other, which would ignore potentially important
   warnings in a test case, which is generally exactly the time when
   it is really useful to get warnings etc.

2. It avoids leaking state, for example in LBFactoryTest the
   assertFalse call would throw a PHPUnit assertion error (not meant
   to be caught by the local catch), and thus won't reach
   AtEase::restoreWarnings. This then causes later code to end up
   in a mismatching state and creates a confusing error_reporting
   state.

See .phpcs.xml, where the at operator is allowed for all test code.

Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
2022-02-24 21:29:51 +00:00
Reedy
12aae45101 tests: Replace some usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I361fde0de7f4406bce6ed075ed397effa5be3359
2022-02-24 12:55:25 +00:00
Arlo Breault
30ae2b3a3b Sync up with Parsoid parserTests files
This now aligns with Parsoid commit 0a99d4ef38f1eba7637e6c0ddb6be434ccd5e72e

Change-Id: I0251d7c56dfb5fa917ab3666a586217e90043bec
2022-02-19 09:58:09 -05:00
jenkins-bot
0a7751dce0 Merge "Revert "Add "resource" attribute to img tags"" 2022-02-19 14:37:42 +00:00
Arlo Breault
4ae0758db2 Revert "Add "resource" attribute to img tags"
This reverts commit 5809ef7caa.

Bug: T292657
Bug: T297984
Depends-On: I261887a3b2d15130894b947d18a2e85537d50a1f
Change-Id: Id4e8d16344ce0f420bfd3e0d5833c67d1cf85fd8
2022-02-18 20:14:20 -05:00
jenkins-bot
99dee6855a Merge "Change return value of ParserOutput::getPageProperty() when property is missing" 2022-02-19 00:49:48 +00:00
Arlo Breault
c5c7d5c9bb Fallback to parser-extlink-target instead of setting link-target
This makes the call to getImageLinkMTOParams consistent between thumbs
and not thumbs by now passing the parser in the former.  The result
being that the nofollow relationship is now added for external thumb
links as well.

Linker::getImageLinkMTOParams sets the parser-extlink-target based on
the same getExternalLinkTarget call.  This also makes it clearer when
parser-extlink-rel is modified by the target in getExternalLinkAttribs.

custom-target-link does have a higher precedence but it looks like this
was added in 1a4957e as a fallback to respect the global config so the
change seems fine.

A few parserTests cover this with the wgExternalLinkTarget config but a
case for thumbs with external links was added.

The phan annotations look like a false positive similar to
https://github.com/phan/phan/issues/3645
from the use of `$params[$type][$paramName] = $value;`

Change-Id: Icf887b13d046b0f610b1984d641f248d1dec5226
2022-02-18 23:06:43 +00:00
Arlo Breault
e4150464f9 Use link-title for manualthumb
link-url for external links, which this isn't and which gain rel
attributes in the follow up.

Change-Id: I968dbb72731b9588fad0fa1e7770c799c0e451a5
2022-02-18 22:26:40 +00:00
C. Scott Ananian
c39ef6c6c9 Change return value of ParserOutput::getPageProperty() when property is missing
The old ParserOutput::getProperty() method returned `false` when a property
was missing.  This requires callers to use the `?:` syntax to supply default
values, which then causes any falsey value to be treated as missing.
So, for example, setting the defaultsort to '0' will cause the default
sort to be ignored.

Modern php convention is to use `null` for missing values, and the `??`
syntax is a better/more restrictive alternative to `?:`.

We renamed `ParserOutput::getProperty()` to `::getPageProperty()` in
1.38 (Ie963eea5aa0f0e984ced7c4dfa0fd65d57313cfa/T287216) but kept the
return value convention.  Before this actually makes it into a 1.38
release, take the opportunity to fix the return value for the new
`ParserOutput::getPageProperty()` method to return `null` when the
property is missing.

We need to do some temporary workarounds to the places we'd
already swapped over to use the new `::getPageProperty()` method
to allow them to handle either `false` or `null` as a return value;
we'll clean that up once this is merged.

Code search:
https://codesearch.wmcloud.org/deployed/?q=-%3EgetPageProperty%5C%28|T301915&i=nope&files=&excludeFiles=&repos=

Bug: T301915
Depends-On: I3f11ce604970e47b41fc1c123792df8c3045626f
Depends-On: Ie7533f49fe4cad01ebfda29760d23c61e9867b10
Depends-On: Ic5c09f5caa4c897bc553c614fbae9cee159566a2
Depends-On: I0278b2eafd90e77e4fee41c45a1165fb79ddf47e
Depends-On: I383abb6b7dc5e96c0061af13957609f6e31a1065
Depends-On: I79f9f4078e415284af29b15047bafd1c823d7f5b
Depends-On: I02276c48c49f5d2d241a69eb0a6cdf439b572d8b
Depends-On: I71628661b4539a4e35ae32846e719f92bcf782e0
Depends-On: I7e215cb43de0ce150a6bcc00f92481dcdcfed383
Change-Id: Iaa25c390118d2db2b6578cdd558f2defd5351d15
2022-02-18 21:15:58 +00:00
jenkins-bot
09621c6758 Merge "Parsoid output now respects thumbsize in parserTests" 2022-01-28 04:14:57 +00:00
Umherirrender
68808e5832 Replace deprecated JobQueueGroup::singleton()
Change-Id: Icdb301d352d302f70fefba9b40df2368cb217fd2
2022-01-27 21:37:50 +01:00
Arlo Breault
1054965edc Parsoid output now respects thumbsize in parserTests
Depends-On: I1ebfe6bf4d5a5be2ed3a1d7ab27cca1886aac3d6
Change-Id: Ic028b729c577bfd5dd30add0c0508e72fee0ca36
2022-01-27 15:06:47 -05:00
jenkins-bot
fd84c0f087 Merge "tests: Replace usages of deprecated WikiPage::doDeleteArticleReal" 2022-01-27 19:32:06 +00:00
jenkins-bot
7958300d13 Merge "Allow parser tests to test the value of extension data and properties" 2022-01-27 19:22:56 +00:00
Thiemo Kreuz
e2a2a393f9 Move property initialisation out of the constructor
When the value is a constant, the initialization can be done
way up together with the property declaration. I believe
this makes the code easier to read because it's not spread
out so much.

Change-Id: I5af482feccb746c144c0f318e119165cf5a56cbe
2022-01-27 18:50:58 +00:00
Ppchelko
44edde6295 Reapply "SettingsBuilder: allow maintenance scripts to manipulate config"
This reverts commit 4f7a4a2477.

Reason for revert: This change is good, just need some preparation in extensions.

Depends-On: I24221be2cedfa132fc94d39d72e4a133cc3cdb12
Depends-On: I5e6119b650e581c6aa5a1132aa071b49cff8b8ca
Change-Id: I5a5a9000751fa3914c9d432eb49475091b3bdb80
2022-01-26 19:21:58 +00:00
Ppchelko
4f7a4a2477 Revert "SettingsBuilder: allow maintenance scripts to manipulate config"
This reverts commit a652f306a5.

Reason for revert: need to prepare extensions first

Change-Id: Iccedf38a8dc964db7c49fd51c971912655122081
2022-01-26 17:24:31 +00:00
daniel
a652f306a5 SettingsBuilder: allow maintenance scripts to manipulate config
Maintenance scripts often need to manipulate configuration settings.
This introduces a way to do this cleanly via SettingsBuilder,
removing the need to rely on global variables.

Bug: T294739
Bug: T294742
Bug: T300128
Change-Id: Ibf443fd564bbbf388cce8ab4dabba55ebca0dfa4
2022-01-26 12:02:56 +00:00
Tim Starling
80a22645f6 Allow parser tests to test the value of extension data and properties
* Add "property" and "extension" options to parser tests
* Slightly refactor the relevant code since it's getting big.
* Slightly refactor the documentation too.

Change-Id: Idc4ac4eb4e20d8e3e2fdbd093ff75f26d3af0d57
2022-01-24 12:46:34 +11:00
Daimona Eaytoy
2688c59606 tests: Replace usages of deprecated WikiPage::doDeleteArticleReal
Add a new helper to MediaWikiIntegrationTestCase, since deleting pages
seems to be pretty common in tests.

Some calls to WikiPage::factory were also updated to use WikiPageFactory.

Change-Id: I5b5100273a00ac292a1900022ca79708fa254347
2022-01-17 15:38:02 +00:00
Subramanya Sastry
1593387f02 Parsoid's parser test runner no longer provides 'scrubWikitext' opt
Change-Id: Ic02221a4fbd9ed76d1f9b8e0968bc7d5500040b5
2022-01-13 16:43:19 -06:00
Arlo Breault
5254ddea2d Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit d9cbfe3ae95ead0111e935f214408ccb49aa12a6

Change-Id: Id5dd98d2bd54187a060ae7523de634747e5d7594
2022-01-07 15:58:30 -05:00
jenkins-bot
7d62f16f77 Merge "Add "resource" attribute to img tags" 2022-01-07 19:23:48 +00:00
Arlo Breault
20be2afb0a Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 1b39be0995a201b4cc949bee32c5964053bdf77e

Change-Id: I243885af834baab178cf4c4fa71de5f59e8609aa
2022-01-05 18:59:28 -05:00
jenkins-bot
38f6a54c1c Merge "Match output for broken thumbnails" 2022-01-05 19:40:23 +00:00
Kosta Harlan
0c2cc804e1 phpunit: Use is_file/is_dir instead of file_exists
Yes, it's a micro-optimization. See https://bugs.php.net/bug.php?id=78285
and https://thephp.cc/articles/caching-makes-everything-faster-right
for more info.

Change-Id: Ib8e8e9794e15066476f35cdb1236df8b983274d6
2022-01-03 21:47:56 +01:00
Alexander Vorwerk
9f9426697c Replace usages of deprecated wfWikiID()
The global function wfWikiID() is deprecated since 1.35 and it's usages
should be replaced with WikiMap::getCurrentWikiId().

Bug: T298059
Change-Id: I22d96b7aec17323d15a9bc401d4511ad2ee14165
2021-12-21 02:05:55 +00:00
Arlo Breault
ad0746110c Match output for broken thumbnails
Follow up to the FIXME added in I6d03037af1b5c90e6d57fd048506da2b4e4bc704

The output isn't great but at least it matches Parsoid's.

Change-Id: I5660b8ccdb8bd0c89b94669a1c6ab260d57183df
2021-12-16 21:23:20 -05:00
Arlo Breault
5809ef7caa Add "resource" attribute to img tags
This is spec'd out at https://www.mediawiki.org/wiki/Specs/HTML#Media

It's also useful in the bug to determine when the link is pointing at
the resource, and hence MediaViewer should open.

Previously that was distinguished with .image class on the link but
that's now omitted in getDescLinkAttribs.

FIXME: Should the "resource" contain querystrings?  Maybe this needs to
be done on the Parsoid side as well.

Bug: T292657
Depends-On: Idb60e418f79dcb6a121de2a11e6e0ed0b31fd3ff
Change-Id: Ia94138383ebdbfc2feef75fdf651b969085a72b1
2021-12-15 19:16:44 -05:00
Arlo Breault
7406194be4 Disable the legacy media dom on a few more tests
Just newer and overlooked tests.  All the media in those galleries are
invalid and the gallery changes went in later in
Iff2bdc3aa02f84f0bf4ca55d177706823934cc08.

Change-Id: I6d03037af1b5c90e6d57fd048506da2b4e4bc704
2021-12-15 16:39:35 -05:00
jenkins-bot
ebbc26296a Merge "Sync up with Parsoid parserTests.txt" 2021-12-10 21:02:23 +00:00
C. Scott Ananian
4f60541f49 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 819630e57c646038215a144fc03e6e9c29c12328

Change-Id: Ia814636d0d8550ebb6c76be6b4b7964b2b5ce105
2021-12-10 14:33:34 -05:00
C. Scott Ananian
b433f53c4e Sync up with Parsoid mediaParserTests.txt
This now aligns with Parsoid commit 819630e57c646038215a144fc03e6e9c29c12328

Change-Id: Iff28d5e009b9555014b7bbf552ef717ae35b6971
2021-12-10 14:32:24 -05:00
Bartosz Dziewoński
dd4d1db814 TestRunner: Set local interwiki URLs to match wgServer, like in production
Matching Parsoid change I6e7bdcdea6bc2fd955f0a04f25f09314ec1230c8.

Change-Id: I6e7bdcdea6bc2fd955f0a04f25f09314ec1230c8
2021-12-07 16:20:26 -05:00
Arlo Breault
3b52802e52 Add project local interwiki to ParserTestRunner
Bug: T228616
Change-Id: Icd659d000445778d4d7c46ad67d96d6df22454e2
2021-12-03 14:47:50 -05:00
Reedy
a349d6b677 parserTexts.txt: Remove usages of "sanity"
Bug: T254646
Change-Id: Iaf8a1df2a88a59e787c0a039c8c7becbd51dfcb5
2021-11-21 23:07:26 +00:00
Amir Sarabadani
afe4bbdbe3 media: Drop XML metadata support from DjvuHandler
All of production has been migrated to json and this patch also adds an
update entry for third parties.

Bug: T275268
Change-Id: I916127896bdce95472823ae7be12fc5e6e16691a
2021-11-21 15:47:56 +01:00
James D. Forrester
20fd877da4 Drop experimental FileJournal system without deprecation
The feature was introduced in 2012 with d19f54602f (just before
the gerrit migration).

Change-Id: Ia3f59ad0ddeb1f610947b14e22b0694ff4c6ed84
2021-11-01 14:08:09 +11:00
Winston Sung
6eda8891a0 Update 台灣 to 臺灣 according to Wikipedia-zh village pump discussions
https://zh.wikipedia.org/wiki/Wikipedia:互助客栈/其他/存档/2019年2月?oldid=61018059#「台灣」「正體」?

Follow-up of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/700626

Change-Id: I6d2a128f682e71312400b97333ffbfffe9968ee7
2021-10-26 11:02:07 +00:00
Fomafix
e86f180bd4 Merge "Encode & to & in displaytitle fallback" 2021-10-14 17:58:06 +00:00