Commit graph

124 commits

Author SHA1 Message Date
libraryupgrader b779ae7026 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.12.1 → 0.14.0

npm:
* grunt-banana-checker: 0.11.0 → 0.11.1

Change-Id: Ib661c3c07825d151bb817a219f3104afbf30ec4b
2024-02-10 10:23:34 +00:00
jenkins-bot b63356e087 Merge "Make the toggle reachable by keyboard" 2024-02-07 14:38:32 +00:00
Nardog 08a23b5c26 Make the toggle reachable by keyboard
Bug: T355636
Change-Id: Ie765cddd664933fa07638c661874bef80782dd45
2024-02-05 06:53:05 +00:00
Umherirrender 1f16baa471 Add return type hint to function in ServiceWiring.php
This is a common pattern for service wiring functions

Change-Id: Ia63bd9a5397b0ea4563f5bb426ed925fc0c40efc
2024-01-31 20:55:00 +01:00
Fomafix 9206c5368b Inject service DBLoadBalancerFactory
Change-Id: I50195f98c2ea130f9dba73e357977653c2fc1a37
2023-11-14 13:40:30 -05:00
Fomafix c63d5da014 Replace global variables by injected Config
Convert some functions to non-static function to access the Config
object.

Change-Id: Iac3d6a6c00eef169aec91b8c367cbbb7359a9b02
2023-11-14 07:15:35 +00:00
Fomafix e492044e44 Inject service LinkRenderer into CategoryTree
Change-Id: Id70e9b26229332889de009b55837dbab6ecbb163
2023-10-29 09:28:03 +00:00
Fomafix e81f6fe15e Move option handling from CategorieTree into new class OptionManager
Change-Id: I0327f7ea6751cdb714308f1ffaf0ab7ac44a3aac
2023-10-29 09:26:56 +00:00
Fomafix 292f21fc38 Get parameters from config instead of global variable in getDataForJs()
Change-Id: Ie01fa1181f6c0878686f056e0a70f89766c090e6
2023-10-05 09:56:03 +00:00
Fomafix 75c2c5580a Simplify PHP code
Change-Id: Ia1bd08cd972b2f5792d24d5fbc383c3c63b000db
2023-10-03 19:38:03 +00:00
Fomafix 8bd82c12f6 Use namespaced classes
Change-Id: I9fabf791aae691dfa7d071a1d99d17f4f7379682
2023-10-03 09:36:31 +00:00
Fomafix b2ef67d9c8 Replace deprecated wfGetDB( DB_REPLICA )
Bug: T330641
Change-Id: Ic2dc694bbb29c3ff315f2be32c24ee6995f9b964
2023-09-20 20:42:06 +00:00
gerritbot 6d296c41ce Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I004e02c6b719be1bbfa1fa19f53e4fab2a7aeca1
2023-08-16 01:54:29 +00:00
gerritbot 0cf8b3dfe5 Update moved class Category
See T321882. Moved in I0b86acfdea

Bug: T321681
Change-Id: If48e9163bcfcfe03098f61b7cc52137e4ecaae82
2023-05-12 14:33:05 +00:00
Umherirrender 3252ddc115 Simplify ApiCategoryTree::extractOptions
Change-Id: I98605b2580a995e37a8da1b88693b38bbd5b8013
2023-04-25 20:06:08 +02:00
Ammarpad 277b547d21 ApiCategoryTree: Harden validation of JSON values in options parameter
* All option values are not expected be object themselves.
* Allow 'namespace' option to take scalar or array value.
* All other options take scalar values only.

Bug: T335145
Change-Id: I3bdb284f26d0c9ee8230f2197b168a7e83c145c3
2023-04-24 23:59:33 +01:00
Umherirrender 6e911fba75 Replace CategoryTreeCategoryViewer with hooks of CategoryViewer
Change-Id: I34a47c4f2f4b08cd3ed8ce5c4a585cc42d44372d
2023-02-28 23:20:56 +01:00
Umherirrender cca06d7656 Remove unused CategoryTreeCategoryViewer::$child_cats
Usage removed in 2009 with r47049 (23187e510a).

Change-Id: Id40904a286de73b0f057243d3f70178b77186d81
2023-02-24 01:09:03 +00:00
Fomafix c1edee1aea Remove flag for ParserOutput
The modules are already in the ParserOutput by change
I8d2a6d92f45f30495263eea716adb4eeaf7ebfbb.
The hack with the flag for the OutputPageParserOutput hook is not
needed anymore.

Do not deploy this change before the caches has been purged or expired.

Bug: T212059
Change-Id: If9427bbf114870ec9747670367915e11750c6525
2023-02-10 12:14:26 +00:00
jenkins-bot 4ead6a9e89 Merge "Add a CategoryCache service for use on Special:TrackingCategories" 2023-01-21 22:33:08 +00:00
Umherirrender 9d98cc1ae6 Add a CategoryCache service for use on Special:TrackingCategories
Replace the dynamic property on SpecialTrackingCategories object,
this was used to store preloaded Category objects.
Dynamic properties are deprecated in php8.2
The preload and storage is now done with the service.

Adjust doc to LinkTarget (Id0cc2ca)

Bug: T324897
Change-Id: I891ad79bc357d32585ef4d9206d398c5a75222aa
2023-01-13 23:05:36 +01:00
Fomafix ed2ec6459b Add modules to ParserOutput
This change adds the modules to the ParserOutput object.

The hack with the flag for the OutputPageParserOutput hook is not
needed anymore. But this will removed in the separate change
If9427bbf114870ec9747670367915e11750c6525 to avoid a caching problem.

This change loads the modules on Special:ExpandTemplates if a
<categorytree> is in the content.

Bug: T212059
Change-Id: I8d2a6d92f45f30495263eea716adb4eeaf7ebfbb
2023-01-12 21:33:16 +00:00
Fomafix 9acd8edf62 Support short link with target in URL path
With this change the following URLs select the target Category:Foo_Bar:
* Special:CategoryTree/Category:Foo_bar
* Special:CategoryTree/Foo_bar
in the UI selector for the category.

Bug: T290070
Change-Id: I169c7c50adb5f6b279c34e44e7fdcf5b1b26c882
2023-01-12 21:08:46 +00:00
Umherirrender 8b4ab1fd43 Use LinkBatchFactory to create LinkBatch objects
Bug: T325591
Change-Id: I3c529e62e45a38e6752f37b6bf36a1e727511e46
2022-12-19 21:37:43 +01:00
Fomafix 828566ef60 Optimize PHP code semantic
* Mark $mOptions as private. There is no external reference.
* CategoryTree::makeTitle don't return false. A check for false is not
  needed.
* A class attribute should not start with a space.
* $title->isExternal() is equivalent to $title->getInterwiki() !== ''.
* Use $title->inNamespace( NS_CATEGORY ) instead of
  $title->getNamespace() === NS_CATEGORY.

Change-Id: Iddad84ff5a18080d1216346ec2a906c955a644a4
2022-11-12 19:08:16 +00:00
jenkins-bot ba6e585427 Merge "Check for null after Title::newFromText" 2022-11-12 17:31:19 +00:00
Fomafix c5b34028e3 Remove phpcs exclude rules and update PHP code
Consistently use single line @var declararation.

Change-Id: I02210ddcc1c523bda6e26adb17e7b6bd38db752d
2022-11-10 20:15:44 +00:00
Fomafix cf8538086c Check for null after Title::newFromText
Title::newFromText returns null on invalid title.

Change-Id: Iaef69584eff33b1b13669f8d0a3b8eeeba3755cc
2022-11-10 19:27:54 +00:00
gerritbot a42526cc2e Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: Ib1ad9e3837bb5030918e84c12c63f570bc67bd3b
2022-04-04 01:24:23 +02:00
Func be3c21741d Follow-up e20262bc: Strip subpage name in action
Thanks to comments on Iaec81a2f, I realized the function of removed code.
Use the native setTitle() method to strip subpage name.

Change-Id: I4b1f48e0b705fb4aa7262454614d90dc1653a4fe
2022-03-27 13:25:57 +08:00
Func e20262bc86 CategoryTreePage: Avoid setting internal fields of HTMLForm
HTMLForm would handle title itself, don't need to set manually here.

Change-Id: Ifff538f48f5578cca5fc7b3a2724e79a851958c3
2022-03-20 21:43:31 +08:00
Ammarpad de9a92c7a3 CategoryTree: Use Category::getMemberCount from core
Core now provides all-member count separately with type guarantee.

Also bump core requirement to >= 1.38.0

Change-Id: I2b489e690ad05462a553e424bd9495593a8d2b1b
2022-02-21 23:15:47 +01:00
Fomafix aec8d75570 Replace WebRequest::getVal by ::getRawVal or ::getText
The UTF-8 normalization of getVal is not needed at all places.

Change-Id: If8fef794ff75671e32f965c7a780681d9cbd9a4a
2021-11-14 18:35:54 +00:00
jenkins-bot 3d8e911979 Merge "ApiCategoryTree: Inject services" 2021-11-11 21:14:53 +00:00
Fomafix 4a3f1aadc5 ApiCategoryTree: Inject services
Change-Id: Id22dbb344307322247c75cde6cf56cccdf012203
2021-11-02 20:13:55 +00:00
Fomafix 06dcae70b4 Get config values from Config instead of from global variables
Change-Id: I316b892ed01472fac75f72f50c820676fb3ce58a
2021-11-01 20:20:35 +00:00
Fomafix 49453bbfde Avoid default value style="display:block" in HTML
This change makes the HTML smaller.

Change-Id: Ie90eb8c85bb530de634bd190290e9aa303018073
2021-09-17 08:55:50 +00:00
Fomafix ed87adce49 Optimize PHP code
* Use ' instead of ".
* Use === instead of ==.
* Use !== instead of !=.
* Use explicit type cast.
* Combine array assignment.
* Use null coalescing operator.

Change-Id: Ic2fe4f62556df77262915b5bcbe1b11a1d907e6d
2021-09-11 21:42:45 +00:00
Fomafix 031e5bf358 CategoryTreePage: Refactor category tree to own method
Use an early return path for not found category.

Change-Id: I49275941ca45b678c5b325966c52c28cb0630d49
2021-09-11 21:03:27 +00:00
Fomafix 509745aaaa Simplify by using Html::element and Html::rawElement
Use element/rawElement instead of openElement and closeElement.

Change-Id: I7229200f073326e66e6bc3c0907da6817777110a
2021-09-11 21:01:03 +00:00
Fomafix a887e226e0 Replace PHP use of Xml class by Html class
Change-Id: I5d98f875566a2ad5da31c707873f3af6d984de34
2021-09-11 21:00:45 +00:00
Fomafix 480ff35722 Add output encoding to $category in not found message
This change outputs the not found category as plain text and prevents
parser processing of the category name like '''bold''' or ''italic''.

This affects the root category of the category tree in the sidebar
like on
$wgCategoryTreeSidebarRoot = "Lista d''e Paise d''o munno"
for a situation without parser and
{{#categorytree:Lista d''e Paise d''o munno}}
or
<categorytree>Lista d''e Paise d''o munno</categorytree>
in the content for situations with parser.

A separation for with and without parser is not needed anymore.
Problem described in T18744 which was the reason for change r49471
(9700e2d5) is not reproducible.

This change also prevents that the value in the parameter `target` on
Special:CategoryTree gets interpreted as wikitext and outputs the value
with an output encoding.

  Special:CategoryTree?target=B%27%27%27o%27%27%27ld%20un%3Cu%20onclick%3d%22alert(%27XSS%27)%22%3Eder%3C/u%3Eline

was rendered as

  B<b>o</b>ld un<u>der</u>line

and is now rendered as

  B'''o'''ld un&lt;u onclick="alert('XSS')"&gt;der&lt;/u&gt;line

The parser prevented already JavaScript injection, so there was no
security issue.

Change-Id: I592b23ba965c15b81a2f97686161a4d590331c87
2021-09-11 20:54:11 +00:00
Fomafix 5e61b40ee0 Restore support for modes for subcategories in Special:CategoryTree
This feature was lost in c839756b.

Before c839756b on Special:CategoryTree the mode was transfered via the
individual global JavaScript variable wgCategoryTreePageCategoryOptions.
c839756b removed the possibility to set the global JavaScript variable
to a page individual value.

Now Special:CategoryTree uses the HTML attribute to transfer the
individual options to JavaScript like at a <categorytree> tag.

Bug: T289997
Change-Id: I706c0ca89d84e3583eeee27a411f734c6969a8b7
2021-09-09 17:20:02 +00:00
libraryupgrader 0c23e8e620
build: Updating composer dependencies
* mediawiki/mediawiki-phan-config: 0.10.6 → 0.11.0
* php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1

Change-Id: I9d26e128cc02d1057b639547e396235e4c3a5a3a
2021-09-08 21:18:55 +03:00
Fomafix 379e090bbc Fix comparison operator in CategoryTreePage#execute
This change is a follow up to a892ae21f7.

Change-Id: Ic71c6f0e57fb2680f5653aac1744132c1f8e64fa
2021-09-03 10:45:31 +00:00
Umherirrender a892ae21f7 Improve string handling around trim()
trim() would always return a string, even with null as input
Keep the strval to make visible that this gets unsafe input

Change-Id: I6ff0ce307f6a8ac21669d6db693e5ff27767a55d
2021-09-02 21:29:25 +02:00
Fomafix 57e7cd356b Remove configuation variable "CategoryTreeForceHeaders"
The configuration variable "CategoryTreeForceHeaders" allowed to force
the loading of the modules on every page by the hooks
"BeforePageDisplay" and "BeforePageDisplayMobile".

This is not needed anymore because the modules are now already loaded
if the category tree is used some on the other hooks.

Change-Id: I9fde894977463ecd1c4b07da449d98c39b3665ea
2021-08-30 07:05:05 +00:00
jenkins-bot 0c5aca0b3c Merge "Remove check for shouldForceHeaders()" 2021-08-30 02:00:23 +00:00
Fomafix 4bc230093f Remove check for shouldForceHeaders()
The CategoryTree::setHeaders() method adds modules to OutputPage.
It does not matter if setHeaders() gets called several times.

The previous code tried to avoid to call setHeaders() several times.
If wgCategoryTreeForceHeaders is set then the modules get loaded by the
hooks "BeforePageDisplay" or "BeforePageDisplayMobile" on every page.
In this case duplicate calls of setHeaders() are (partly) avoided by
not calling setHeaders() on other hooks.

This change removes this micro optimization and loads the modules
unconditionally if a category tree is added on a hook.
shouldForceHeaders() is now inlined.

Change-Id: Ic9219575a714886b4edd446efde2a330dff4dee6
2021-08-29 11:14:21 +00:00
jenkins-bot 6cba244a94 Merge "Simplify CategoryTree::capDepth" 2021-08-24 09:30:11 +00:00