Commit graph

90 commits

Author SHA1 Message Date
Sébastien Beyou 3ab47c1061 Add a parameter to deactivate OpenGraph meta tags
This can conflict with other extensions like SemanticMetaTags or
OpenGraphMeta.

Bug: T217307
Change-Id: Idfb006583edda8545b95609f047b2f301a9caa33
2022-08-20 09:43:57 +02:00
Kosta Harlan 8adbbf5b8c
SearchResultProvideThumbnailHookHandler: Simplify code
Bug: T312746
Change-Id: Iaf3f7f56129f488088f08f65657fa33f6a6e5851
2022-07-18 10:13:42 +02:00
Reedy 84861174bc Convert Hooks to HookHandlers
Bug: T271021
Change-Id: I6022e515cf65ec089c59fb56f6fde371dc9f0e12
2022-07-07 10:21:43 +00:00
gerritbot d0f26549f2 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: Ie88e576d3a6dc61155f2b7f49e86a993c2577427
2022-04-04 00:32:20 +00:00
gerritbot c2ee690bdd Replace deprecated ApiBase::PARAM_ with IntegerDef ones
The rest of ApiBase::PARAM_  will be done in separate patches

Bug: T275455
Change-Id: Ia64fadade6a890827bfb2b220e430c16716e86f7
2022-04-03 22:16:07 +02:00
C. Scott Ananian 8d62412484 ParserOutput::getPageProperty() now returns null when key is missing.
The return value of ParserOutput::getPageProperty() has transitioned
to returning `null` instead of `false` when the page property is missing.

Bug: T301915
Depends-On: Iaa25c390118d2db2b6578cdd558f2defd5351d15
Change-Id: Ie746883bd14eb579b40390d5fe824a5c6f93fa1e
2022-02-16 18:37:52 -05:00
C. Scott Ananian e9b268827f Update uses of ParserOutput::getPageProperty() to handle new return value
The return value of ParserOutput::getPageProperty() will transition to
returning `null` instead of `false` when the page property is missing.

Bug: T301915
Change-Id: I383abb6b7dc5e96c0061af13957609f6e31a1065
2022-02-16 18:37:52 -05:00
Simon Legner 41f4165230 Allow editors control of the page image
- Exclude images with class=notpageimage

Bug: T301588
Change-Id: I15eb580f5047a414431a45acf4004344e01a5881
2022-02-14 18:53:57 +00:00
Tim Starling 768464d0f9 Identify lead images using a new parser hook instead of during LinksUpdate
I added ParserModifyImageHTML to core to make it easier for PageImages
to identify images in the lead section.

This also allows PageImages to stop writing to LinksUpdate properties.
It is one of only two extensions that do that.

Depends-On: I24528381e8d24ca8d138bceadb9397c83fd31356
Bug: T176520
Bug: T296895
Change-Id: I472f4a023969bfde6298eb56112c16d2ae842199
2022-01-04 14:19:32 +11:00
Roman Stolar 6b4da12fd6 Replace deprecated Content::getParserOutput call to new one ContentRenderer::getParserOutput
Bug: T287158
Change-Id: Ia537b3a496e48237d427ad61a6db6268f63c769e
2021-10-21 18:19:03 +03:00
Alexander Vorwerk 7b03392757 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I5a60221692f3538dd96651493fc8d392aaabdf85
2021-10-12 00:57:52 +02:00
jenkins-bot f908355d17 Merge "Add a configuration to provide the fallback of og:image" 2021-07-28 16:03:39 +00:00
libraryupgrader 2f4755e065 build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: I314da8a48195e98aed3605f18e9d0eab516ba026
2021-07-23 05:46:22 +00:00
lens0021 d526653e3a
Add a configuration to provide the fallback of og:image
Makes the fallback image be used when there is no image on a page.

Bug: T256935
Change-Id: I0bc4d55b20cc37edf46cb984a9a68617e2b4a89f
2021-06-18 12:16:36 +09:00
jenkins-bot 5bad40f6f8 Merge "Use PageIdentityValue instead of SearchResultPageIdentityValue." 2021-05-13 20:35:15 +00:00
libraryupgrader 668d044574 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

npm:
* grunt: 1.3.0 → 1.4.0
* lodash: 4.17.19 → 4.17.21
  * https://npmjs.com/advisories/1673 (CVE-2021-23337)

Change-Id: I6797ecfc38973777657d1d4611363595b23e4afd
2021-05-12 19:05:01 +00:00
daniel ccedc7a921 Use PageIdentityValue instead of SearchResultPageIdentityValue.
Depends-On: I6eb55c78a0a72be66814f8bc854ba663e7c6f62b
Change-Id: Idc20c479defe5ce377046172a639c89d6fc4e8f6
2021-05-12 01:01:12 +00:00
jenkins-bot 738e91e19c Merge "Pass wikiId to constructor of SearchResultPageIdentityValue." 2021-05-12 00:44:36 +00:00
daniel 985dfba509 Pass wikiId to constructor of SearchResultPageIdentityValue.
SearchResultPageIdentityValue will become an alias for
PageIdentityValue, which requires the forth parameter.

Needed-By: I6eb55c78a0a72be66814f8bc854ba663e7c6f62b
Change-Id: I9b1ab02e0acf12ace107361ea2c443aa543c4880
2021-05-10 16:09:12 +02:00
Clare Ming 4bb7aface9 Address voice and tone issues.
Replace instances of "blacklist" with "denylist" throughout extension.

Bug: T277955
Depends-On: Ib4985ec2fcb22eafad8f3a7cf9fc3161782a71db
Change-Id: Ibe460cb9691d56a9e83686b53c7629b5404af6fb
2021-05-07 20:39:38 +00:00
jenkins-bot 2a963b67ff Merge "Update PHPDocs and use PHP7 features where possible" 2021-05-04 18:31:58 +00:00
DannyS712 273dfc5cee ApiQueryPageImagesTest: fix parameter order in assertions
Expected first, then actual

Change-Id: I13849d517a5c018133fb2111cd0d19c965dc3735
2021-05-04 16:44:00 +00:00
Thiemo Kreuz d8eceed585 Update PHPDocs and use PHP7 features where possible
Change-Id: I417ad041e268b88512de435c59695cb4338331cc
2021-05-04 16:51:18 +02:00
Thiemo Kreuz c386aa5328 Remove unnecessary boilerplate from PHPUnit test setups
* any() doesn't do anything. It's the default anyway.
* Prefer the more strict assertSame() where possible.
* Use shortcuts like createMock() where possible.

Change-Id: Iff33f111312448e9fc8ff827e2ef9eb2b583ff6f
2021-05-04 16:50:15 +02:00
Umherirrender de2ea3885e Use ::class for class name
Change-Id: I97d470bf535c3141e0443ef0aaf8784b02dd4240
2021-04-08 21:15:01 +02:00
Reedy 36d64ba6d6 Test cleanup
Change-Id: Id0eab4d331fd178c69fe29efd3d7fd10c6503eaf
2021-03-20 05:22:04 +00:00
Umherirrender f9fb414b22 Add missing @param to test
Change-Id: Ibb7db4ac089e0d639540dfc96d1f6339b1bda9e0
2021-01-23 16:18:08 +01:00
Petr Pchelko 6fa0a18037 Stop writing objects into ParserOutput::setExtensionData.
As we switch ParserCache to JSON, we can no longer serialized
class instances in extension data. PageImages was writing the
full set of properies it received from Parser into it's extension
data, some of which are sometimes class instances. Instead, only
write the nessessary subset of data into extension-data.

This change is completely forward and backward compatible.
Since before this change we were already writing the same array,
but with many additional unused properties.

Bug: T266251
Change-Id: Ieb4a139465159611e6b3a99c4b68c3c174b1944f
2020-10-26 13:35:38 -07:00
jgiannelos d9fd6c8679 Add language param in prop=pageimages API
* Images on pages can be localized (eg. SVG text)
* Allow API consumers to select the language the images are rendered in

Bug: T257082
Change-Id: I05f498444c55aea9028a58de80e21ba1e236bf02
2020-08-19 11:59:05 +03:00
Umherirrender 1476a7238a Use MediaWikiIntegrationTestCase::overrideMwServices for RepoGroup
Also use ::class feature to refer to class names

Change-Id: I147f5adefbae9dfe79beb7f193ce0bca8f4a58b5
2020-05-26 22:28:53 +02:00
Peter Ovchyn 6e004092ca rest: Verify that file exists before calling filesize
Bug: T252128
Change-Id: I2de87d723fdd99bea0f1dadd23648470759a103e
2020-05-07 19:33:49 +03:00
Peter Ovchyn 34f54dd1ad rest: Implement SearchResultProvideThumbnail hook
SearchResultProvideThumbnail was introduced in T250144. In order to fill
search results with the "thumbnails" field it should be implemented in proper extension.

Bug: T250207
Change-Id: I81d5d70f5237d6399b8ec6bec3058d12e40ca142
2020-05-06 22:52:49 +03:00
Reedy e688856810 Remove un-namespaced PageImages class
Change-Id: If761744fdc969e395a7cf7944ed6bf3738635384
2020-05-01 01:36:20 +00:00
Reedy 0a406c67a8 Add TestAutoloadNamespaces
Remove require_once from ApiQueryPageImagesTest

Change-Id: I0d1cf452a3c88e0cbac4c44284b7dc673bbca886
2020-04-19 23:14:24 +00:00
Reedy b14685b8d5 Namespace the other two classes in PageImages
Leave alias for PageImages as it's used elsewhere...

Change-Id: I4a3fa5f8aaafd87c78b03f04369a73f4b4f1b189
2020-04-19 23:06:20 +00:00
DannyS712 f22926df87 Use LinksUpdate::getRevisionRecord in MW 1.35+
Bug: T249397
Change-Id: I59759823a98f25dbfa633288a849aa9e01014683
2020-04-08 01:32:14 +00:00
jenkins-bot 4ab449ac8d Merge "Remove usage of deprecated Revision::newFromTitle" 2020-03-11 14:08:33 +00:00
Daimona Eaytoy a39d6acb00 Avoid using Title::__construct
Change-Id: I951e412b3f4d7813bb27b9895148ccc59dfd154f
2020-03-07 13:14:08 +00:00
Petr Pchelko 381512b11f Remove usage of deprecated Revision::newFromTitle
Bug: T246284
Change-Id: I4e0a197bbc51b4d05e6519fb2447c0f791d40380
2020-03-03 20:26:09 -08:00
libraryupgrader 712d006ba3 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I5e714b548aa11857b5631df94c075fa0e4e7ce81
2020-01-14 08:48:00 +00:00
Umherirrender 0de5777cf7 Optimize ApiQueryPageImages::getTitles
Avoid array_map/array_flip + foreach when doing the simple thing also in
the foreach

Swap Title::newFromText to Title::makeTitle to avoid reparsing the
string

Bug: T237068
Change-Id: I745cb9bd817a4b2274c6f778c38c58846ef318c1
2019-10-31 23:08:13 +00:00
Kosta Harlan 47660475b9 Tests: Stub getRequest/getConfig for OutputPage mock
Needed due to I4bf53dabb6e6c5446cea99a64db68b300cef2fd4

Bug: T236723
Change-Id: I8505d2dad69aefed5f8ed1f599b3ca1b7e79acf5
2019-10-29 12:23:57 +01:00
James D. Forrester a9518ea914 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Ic742e7cde506b7d0c1865453cc8895faefe10e90
2019-10-11 11:05:53 -07:00
Max Semenik 0665baacc3 Fix PHPUnit 4 rudiments
Change-Id: Idcba8dce56f7a5deea7f8dd5a126c7bdfa499064
2019-10-04 19:16:34 -07:00
Thiemo Kreuz 71b5c4db22 Relax score calculation in LinksUpdateHookHandler to use floats
This allows to use floats in the $wgPageImagesScores configuration.
Before, decimal places have just been cut off with no warning. I find
this pretty unexpected. When I see the terminology "score" being used,
I always think of float values. I checked all the code that consumes
these scores (it is all internal to LinksUpdateHookHandler), and it's
all fine with floats. I don't see a reason to forcefully cut decimal
places off.

Bug: T212013
Change-Id: I0f1f0ea0865f07b3e58a2fc142dcd838eb687c97
2019-01-10 09:31:20 +01:00
Thiemo Kreuz 0fd9a2b5f4 Fix score calculation in LinksUpdateHookHandler failing on unordered input
This patch is motivated by Iad694e0.

* I rearranged the code a little bit to avoid a duplicate line of code.
* I added a ksort() and a comment explaining it.
* Additional tests demonstrate why the ksort() is needed.
* I had to refactor the tests a little bit to allow for more test cases
  that have been missing before.

Bug: T212013
Change-Id: Ia96dc8c6cf57ddcea410a7300756d0013052ac79
2019-01-10 09:26:54 +01:00
Thiemo Kreuz baabc300ba Remove bogus @doc… elements from default $wgPageImagesScores setting
Such @doc… keys are not allowed at this level. They make it to the code
and cause confusion there. I added a test case for an edge case where this
really causes wrong results.

Bug: T212013
Change-Id: Ib391e5639ef5a34f9ee44f8c19b99e1dd19207bc
2019-01-09 12:41:21 +01:00
Kunal Mehta a9ad31c7f8 Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag issues
Change-Id: I3b0c14dcd5961254d49a98df4061f8ff83589f3a
2018-05-24 21:42:59 -07:00
Kunal Mehta 34b0dd5ff6 Unbreak test that only worked by accident, and fails on PHP 7.2
`$leadImages || $images` will return a boolean, it doesn't work like
JavaScript or Python. Use `?:` to implement what was wanted.

This only worked because `count( true ) === 1`. Using assertCount()
would have caught it also.

Change-Id: I11357b23ad1124ed96d863872014cdca7c59e284
2018-04-13 22:25:26 -07:00
Kunal Mehta b138993e96 Properly specify method that will be mocked
Change-Id: I2bb3b586727a4a7c52f4fd8813f87d0a4e7c5952
2018-04-13 22:20:17 -07:00