Commit graph

183 commits

Author SHA1 Message Date
Andre Klapper 871cb29005 Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: I2f17c7e8c6365795f7a54738b0e607b6f35c9df2
2024-10-26 15:09:27 +02:00
Umherirrender 198b3e7f68 Use type-declaration on api module constructor
Parent class constructor gets type-declaration in 1145328459
Remove simple doc-blocks without further information

Change-Id: Id2264c743077188e2b4f6a66b5d32d67716ed182
2024-10-25 20:16:38 +02:00
Umherirrender bbbcca4b38 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I6b49b9837ed6d3dfdd8a4bc0420848c09fcb1540
2024-10-20 11:10:45 +02:00
Umherirrender 3703c048cc Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I780e57da1ea02eb333cf61abd999dc737acf20d1
2024-06-09 19:03:17 +02:00
jenkins-bot 6384abe012 Merge "Replace deprecated ApiPageSet::getGoodTitles" 2024-04-29 11:24:27 +00:00
Umherirrender d0c0dc9caf Migrate to IReadableDatabase::newSelectQueryBuilder
Also use expression builder to avoid raw sql

Bug: T312501
Bug: T350988
Change-Id: I0ea6aa6edcd68cba067260dad560b87283cca020
2024-04-22 18:58:42 +00:00
Fomafix 6c80d95abe Use MainConfig instead of global variables
Use overrideConfigValue instead of setMwGlobals in tests.

Change-Id: Ifd7bd498bbb9a405afd9f6dd0e80540412b6ff93
2024-04-10 20:05:26 +00:00
Umherirrender beef358191 Replace deprecated ApiPageSet::getGoodTitles
Remove Title objects from the data provider and use PageReferences

Bug: T339384
Change-Id: I3ff14424c5caa9e4436dfe62052a6c95d30ac89f
2024-03-29 21:05:13 +00:00
Umherirrender bbb00c0f2d build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: Ied844c3ae930a03ca49e36e9a9e9d0c008d2634c
2024-03-11 20:13:21 +01:00
Arlo Breault d031b380db Stop stripping comments in TOC data
The parserTest "PageImages with toc and image in heading" covers the
case of PageImages comments being left around in TOC data.

Depends-On: I10f96435f892b188cffe64b92cdf2701a3e2058b
Change-Id: Ie6760dd25f937d4f6acbab1c0e1475b54878d4ed
2024-02-29 16:07:57 -05:00
Arlo Breault abf45611d7 Strip comments from toc section lines
Change-Id: Ide4462b9df5d02b088bf2f1c83a3c5f119366a95
2024-02-19 17:57:40 -05:00
jenkins-bot 774edf893e Merge "Rely on language-level types for the constructor" 2024-02-10 14:47:45 +00:00
thiemowmde ffeb714a6e Various code style updates in ParserFileProcessingHookHandlers
Notably:
* Utilize the new ??= operator.
* No need to count when nobody cares about the number.
* More robust ratio calculation.
* More straightforward check for the "notpageimage" class name. We
  don't need an array of all the classes when all we care about is a
  single, specific class.
* Fix misspelled "no(t)pageimage".

Change-Id: Ibad1d395a5438bc58e026022d08c38fe54c48653
2024-02-08 12:15:05 +01:00
thiemowmde 692b0bc370 Rely on language-level types for the constructor
… as well as the properties that are initialized via the constructor.

Also update some PHPDoc comments.

Change-Id: I2f1dc5345b4a9d00e01d701ad04d42b28aa2f96a
2024-02-08 12:09:56 +01:00
Umherirrender 15dbbe94d5 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ie00aedfe607665e8a38ee4ce2475f25b82a1d8cf
2024-01-05 22:37:40 +01:00
jenkins-bot 04eca18ed1 Merge "Use a return type hint for PageImages::getPageImageInternal()" 2023-11-30 10:36:46 +00:00
gerritbot e2986d0527 Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: I50d14c08f9d10c5fc7aee2a3908c7ed1d9fad050
2023-11-29 12:39:39 +00:00
Amir Sarabadani 9c24383f80 Only take one field in fetchFieldValues
That is causing T350726 and we already set the field in one line above

Follows-Up: I63ac37c2b73073e8e323f6627785955196cd148c
Bug: T350726
Change-Id: I9f28e326aefa206fe8f4d3f6a1038740fed9b0d4
2023-11-08 12:00:09 +01:00
Amir Sarabadani 5ffaf34258 Add support for read new of pagelinks migration
Bug: T346457
Change-Id: I63ac37c2b73073e8e323f6627785955196cd148c
2023-11-01 18:51:38 +01:00
Fomafix 4b86859269 Use a return type hint for PageImages::getPageImageInternal()
Now getPageImageInternal returns null instead of false.

Fix the comment in fetchPageImage(): false means no cache.

Also add a return type hint to PageImages::factory().

Change-Id: I696f24390be530e7eea21957e0e46752d1bb3030
2023-10-21 13:06:16 +00:00
jenkins-bot 421e55b852 Merge "Inject service RepoGroup in APIPropModules" 2023-10-16 03:18:32 +00:00
jenkins-bot abfaa34709 Merge "Replace deprecated global function wfGetDB()" 2023-10-16 03:06:07 +00:00
jenkins-bot 053957162a Merge "Inject service RepoGroup in PageImages" 2023-10-16 03:06:06 +00:00
jenkins-bot df9b7a9c92 Merge "Convert PageImages::fetchPageImage to a nonstatic method" 2023-10-16 03:05:22 +00:00
Fomafix 21fdd8a9db Inject service RepoGroup in APIPropModules
Change-Id: Ifa1334391af08f09908a92f0a9b7774eda58c399
2023-10-15 20:17:05 +00:00
Fomafix 318407932c Replace deprecated global function wfGetDB()
Bug: T330641
Change-Id: If0427da7a6d2de9d1ec00bf1ff7e5b8a495617e9
2023-10-15 18:50:46 +00:00
Fomafix 029af825a9 Inject service RepoGroup in PageImages
Change-Id: I91d12fe25fbd6ee952d635cd24b5047be8790c80
2023-10-15 18:33:00 +00:00
Fomafix 1f95b141a6 Convert PageImages::fetchPageImage to a nonstatic method
The public static function PageImages::getPageImage must stay unchanged
because this function is called by other extensions.

Change-Id: I73f7253581ebc894ef6dcd41bd4713f7d9f53421
2023-10-15 18:21:40 +00:00
Fomafix efa6c4f0ce Inject services on JobClasses
Change-Id: Ic0e965dca31b41ab76e59a3d2672069464418de8
2023-10-15 13:52:13 +00:00
Umherirrender 09d47340eb Use the expression assignment operator to simplify code
Suggested by phan, available since php7.4

Change-Id: Iadee84c7b62f9aeac31ade702bc33764d35ef9c8
2023-10-14 00:55:37 +02:00
jenkins-bot aef7d17348 Merge "Use namespaced MediaWiki\Request\FauxRequest" 2023-08-20 01:07:09 +00:00
Umherirrender b8dd616a03 Use namespaced MediaWiki\Request\FauxRequest
Bug: T321681
Change-Id: I9c6b8bfc935a47c62c3e106a1bf4532ef4d12134
2023-08-20 01:54:45 +02:00
Umherirrender ec4d1bed4d Use namespaced MediaWiki\Page\PageProps
Bug: T321681
Change-Id: I5298c09e2869a21e6616cb6e8917da51177c7987
2023-08-20 01:21:38 +02:00
gerritbot a85ae32a5e Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I80f2f9cdd569d549de8b403226000bb5c88fcb67
2023-08-19 04:18:19 +00:00
Umherirrender 7f3a11f327 Use HookHandlers for MobileFrontend hook
Bug: T271021
Change-Id: I9293e1fee102b9a4274ef460b9c7556e0c7c6f6a
2023-08-15 10:03:09 +02:00
Umherirrender a85ff941ef i18n: Split apihelp for parameter prop=pageimages&piprop=
Easier to translate
There is no visible change on Special:ApiHelp/query+pageimages

Enable use of existing paramvalue apihelp messages for pilicense

Bug: T285545
Change-Id: Iea70490705af9224b3c93669bd5a6e9be7043410
2023-08-05 02:20:47 +02:00
Umherirrender 619d623104 ParserFileProcessing: Inject TitleFactory
Check the parsed title if valid and can exists on the database

Change-Id: I32805de6ab4b9dca7d56faf982762f6949fc3203
2023-06-21 23:03:44 +02:00
Umherirrender a9b4b4877f ParserFileProcessing: Use ConnectionProvider and QueryBuilder
Bug: T312501
Change-Id: I4c5b5b773cbf1bf77dae7c189f65c8760091e384
2023-06-21 22:50:19 +02:00
Umherirrender 3ae938a116 Use renamed ParserModifyImageHTMLHook interface
Follow-Up: I3043454a502289e5ee2492f7bf2ab01e155c30ba
Change-Id: I3cc4a5d4e4edac76e81c16c1da97427d765cce49
2023-04-22 19:54:54 +02:00
Umherirrender 00ec4349d4 Use PageReference on ParserFileProcessingHookHandlers::processThisTitle
Avoid deprecated Parser::getTitle
Parser::getPage can return null, so checking for that as well

Change-Id: I90f04d514934621ee7fdc0ebe519673d7ba1d82f
2023-01-03 23:32:11 +01:00
Umherirrender de7bf883d2 Replace deprecated Http::get
Bug: T305813
Change-Id: Icd3e64fc13e291761b287c4059315df39cd88d1e
2022-12-11 15:54:20 +01:00
jenkins-bot 7245136ded Merge "Adopt getWithSet idiom for getPageImage in-process cache" 2022-11-29 06:07:56 +00:00
Timo Tijhof d50f90ba78 Adopt getWithSet idiom for getPageImage in-process cache
Follows-up I9b08b4de2648bf.

Bug: T322528
Change-Id: I8e974b66e3a0cdee2c6ef5eeb38719cff60dc93c
2022-11-23 01:38:14 +00:00
Amir Sarabadani 8fe805f25e Make sure pithumbsize set width and not height
This unifies image thumbnail sizes so instead of being random image
sizes, it would be only one thumbsize.

Bug: T323223
Change-Id: Ib7a7a5bce3ce10e60819e6ca056fe30f11e969a5
2022-11-21 19:52:44 +01:00
jenkins-bot e588a4eeff Merge "Add in-process cache for result of getPageImage() DB query" 2022-11-17 16:21:41 +00:00
Matthias Mullie c75b00d14d Ensure array is passed to getProperties
PageImages::getPropNames can return either array or string,
and PageProps::getProperties accepts both.
But the latter's return value will be different depending
on the type of input: with an array as input, the returned
array's values will be an associative array where the index
is the propname; with a string, it's just the propvalue.

This difference matters because the code below assumes an
array with propname keys.

Bug: T323152
Change-Id: I422951ec0cd5c651b32c65e88a557d49f2f22712
2022-11-16 09:33:37 +01:00
Amir Sarabadani bb555ae71d Add in-process cache for result of getPageImage() DB query
There has been cases of different extensions calling this function
for the same page title within the same web request, leading to
duplicate queries and roundtrips. This avoids those.

Maybe in future we could have APCu cache for it.

Bug: T322528
Change-Id: I9b08b4de2648bf794bfdbfe57de9db433cfd79ee
2022-11-15 20:18:43 +01:00
jenkins-bot d7d9c0275f Merge "Only provide free images for search purposes" 2022-11-10 17:48:20 +00:00
Matthias Mullie 5dcd4d13e2 Only provide free images for search purposes
Bug: T320661
Change-Id: Ic26e7e815365f6aa81b6fbfb464d0f41b80e4ae8
2022-11-10 13:26:56 +01:00
Tim Starling 33ee32f448 Use preg_replace_callback() flag introduced in PHP 7.4
Should improve performance by avoiding the need to run the regex
twice.

Change-Id: Ic737c1c2189c1bfc046cdcb099cdcbc0edde0a97
2022-11-10 13:58:31 +11:00