Commit graph

97 commits

Author SHA1 Message Date
Umherirrender 01ff6fd116 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
(cherry picked from commit 9d98cc1ae6)
2023-01-22 10:27:23 +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
Fomafix 0bfff67aac Move bullets from HTML to CSS
This allows better to style the buttons.

The complicated CSS selector for the direction supports a categorytree
in the user interface language like in the sidebar or on
Special:CategoryTree and in the content language like on category pages
and with <categorytree> in the content.

The CSS selector :dir( rtl ) would be a short version for this but it is
currently only supported by Firefox:
https://developer.mozilla.org/en-US/docs/Web/CSS/:dir

Bug: T288910
Change-Id: Ibfb0cb28f0086fb1b7d0997be2246bc120eea85e
2021-08-21 14:50:15 +00:00
libraryupgrader 97d57800a8 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.0 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I3661ee3bfb047c9f43ef02bb4052196913c5b38d
2021-07-22 11:41:27 +00:00
Matěj Suchánek c7b79338d5 Simplify CategoryTree::capDepth
Current master of CategoryTree requires MW 1.35, which requires PHP 7.3.

Change-Id: Ibec271bf45465cd61ac383595041e0475304f31c
2021-07-07 12:42:08 +00:00
daniel 734e2af35c Put onMediaWikiServices into a separate handler class.
The MediaWikiServices hook runs before the service container is fully initialized, so it cannot have services injected. For this reason, it needs to be separate from the handlers for other hooks.

Change-Id: I1519aea8bca2f3977fcf15ee8776a1b3319687b5
2021-06-24 15:17:34 +00:00
jdlrobson 46d2de89da Restore category link to sidebar
Bug: T272705
Change-Id: I2911562a902aab82783d696282bbbdd2a287e962
2021-06-15 11:55:22 -07:00
daniel ece310d7be Re-apply: Convert to new hook system (Workshop)
This converts the CategtoryTree extension to the new (MW1.35) hook system.
The patch was written live during a hackathon workshop.
A recording of the workshop is available at
<https://www.youtube.com/watch?v=ZOj44Rbh0tM&t>.

Re-applying after fixing: premature access to $wgRequest
Restores change: Ie52c393af378a980a2dac4ae7076fd6c016a8e0e
Reverts revert: Ieee300c7b35b7069bd7e781610c915f2ecae1bf1

NOTE: the "mode" parameter for category pages seems to be broken,
as the mode is not proeprly propoagated to dynamic requests.
This was already the case before this change, and this change
does not try to fix that issue. I was tempted to just remove
the feature entirely, but T137812 inidcates that it may be useful to
some. I will comment there to see if this should be fiexed or removed.

Bug: T282110
Bug: T271011
Change-Id: Ic3ee05e9dc382f4ada5cfeb9ff5d9a69249cc60d
2021-06-11 11:20:38 +02:00
libraryupgrader e2ee5bff3c build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I6daf5f05db0a1db2c3089dc1be047b752d52c4ec
2021-05-04 01:18:21 +00:00
Reedy 03685efdba Namespace extension
Change-Id: Idf4fbb9ff0c11b9da0b48b3843b2c87c155a4c36
2021-04-08 01:28:21 +01:00
Reedy 7dbedfde4d CategoryTreeHooks: Move call that is independent of a loop
Change-Id: I0901aad1581a2b679bcb68b3c7a733f9db9be81c
2021-04-07 22:34:36 +00:00
Arlo Breault c08dc34b1d Return an extension tag when preprocessing a parser function
Help out Parsoid since it doesn't have support for the "isHTML" flag.

Bug: T257344
Bug: T279094
Change-Id: Ia3295e74628bb45912e208c38da8c85cdb736d0b
2021-04-01 17:54:49 -04:00
Umherirrender bf876f5c19 Inject services into SpecialCategoryTree
Bug: T259960
Change-Id: Ie2a3156f1be52074f28b24507815aef7a746f083
2021-03-12 21:34:50 +01:00
Umherirrender 63b9527d9c Use IContextSource::getConfig to access configs stored in globals
Change-Id: Id48a17ee63ea7d9629f103bd1cb6ca2f6489d484
2021-03-12 20:40:10 +01:00
Daimona Eaytoy 7acc45f672 Stop using deprecated Language methods
Change-Id: Ibcb9cf30dd6e7a496a6cbe6ceab871a4405e0642
2021-02-27 13:59:57 +00:00
jenkins-bot 1cf89c5bb1 Merge "Fix category tree headers not being set" 2021-01-04 17:19:02 +00:00
Petr Pchelko 7659fe8b89 Remove fallback for ParserOutput dynamic property
Bug: T269235
Change-Id: Ief11ffc919d01f45179612fe072950ee279eaab0
2021-01-04 10:24:04 -06:00
Taavi Väänänen 7e6fb72e60 Fix category tree headers not being set
Bug: T270360
Change-Id: I01c81b3cc5ce3ddfd4de5b9524a5402805a46f9a
2021-01-01 20:17:49 +02:00
libraryupgrader 44c2059ac3 build: Updating mediawiki/mediawiki-phan-config to 0.10.5
Change-Id: I839cd5acfdd3022551f77a4f432bdce7920150dd
2020-12-09 21:47:40 -08:00
Petr Pchelko 32d1bf0c1f Use ParserOutput::extensionData instead of dynamic properties.
Bug: T269235
Change-Id: Iecae25e3210d043e895d8d6dd62138910e0d6b14
2020-12-02 08:50:14 -06:00
libraryupgrader 8e493d1ee8 build: Updating mediawiki/mediawiki-phan-config to 0.10.4
Change-Id: Iae62c679581802b471dc005b3004d2965e0d96e8
2020-11-19 21:11:16 -08:00
libraryupgrader 44998a759a build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic
* MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage

Additional changes:
* Dropped .inc files from .phpcs.xml (T200956).
* Added the `wikimedia/mediawiki` profile in .eslintrc.json (T262222).
* Added the `wikimedia/jquery` profile in .eslintrc.json (T262222).
* Removed global `$`, included in the `wikimedia/jquery` profile (T262222).
* Removed global `mw`, included via `wikimedia/mediawiki` profile (T262222).
* Dropped the emtpy global definition in .eslintrc.json.

Change-Id: Ib5a3697712078a4ed22195c274eae9c82ddd7227
2020-10-29 07:51:57 +00:00
libraryupgrader 31161f5fff build: Updating mediawiki/mediawiki-phan-config to 0.10.3
Additional changes:
* Dropped .php5 files from .phpcs.xml (T200956).

Change-Id: I7b48e4e6f67e8b8d2f885b6d6f39861d9d6a0cf4
2020-09-25 00:16:38 +00:00
jenkins-bot a27b54d610 Merge "Fixed a bug that double percent-encoding on Special:CategoryTree" 2020-07-23 09:23:25 +00:00
Umherirrender c1ff28f077 Update signature of CategoryTreeHooks::parserHook
Parser.php gives 4 argument and that includes a PPFrame
That is overridden the $allowMissing arg

Change-Id: Ibf69be346e5f6abbf113ad51155d94d14510ef95
2020-05-31 14:48:37 +00:00
Umherirrender 0625a871d5 build: Bump phan to 0.10.2, remove taint-check
Phan failure fixed in follow up

Change-Id: I980a39b4446b25be90e1774cc6385aad8d6318d5
2020-05-31 16:46:45 +02:00
Yuukin256 b3fa4441a0 Fixed a bug that double percent-encoding on Special:CategoryTree
Special:CategoryTree shows wrong link to parent category that containing string that need percent-encoding.
Changed getPartialURL() to getDBkey() on CategoryTree.php. getPartialURL() returns a percent-encoded URL and getDBkey() returns no encoded URL.

Bug: T253621
Change-Id: Idffb8ffece88a1d726075ffee9d64e6e05ed4e52
2020-05-27 22:36:50 +09:00
Aaron Schulz f7233850e4 Convert $wgMemc use to WANObjectCache
Bug: T160813
Change-Id: Icacecf5ecc4260385a95b99f5a491a58175c14de
2020-03-30 14:11:50 -07:00
libraryupgrader 4180323699 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I5f4050a13d1ac8db56adebe8d4bf13b84da5545a
2020-01-14 03:58:43 +00:00