Commit graph

41 commits

Author SHA1 Message Date
jenkins-bot cbde447eaf Merge "Remove unused parameter PPFrame $frame" 2024-11-04 17:47:02 +00:00
Fomafix 46defa6251 docs: Replace CategoryTreeFunctions.php by CategoryTree
In 8e51ea4e3a CategoryTreeFunctions.php
was renamed to includes/CategoryTree.php. The class name was already
CategoryTree.

Change-Id: I2734c92810df0f653ae1ea402a149e42e7be08cb
2024-11-04 14:26:13 +00:00
Fomafix 2b55cfe576 Add type hint for parserHook
On a self-closing tag the first parameter is null.

Change-Id: I7a8cee1cb517a5b565617cdf5e1b1aeeb03b8de1
2024-11-02 10:19:51 +00:00
Ammarpad a925bb10cd Fix handling of self-closing tag
self closing tag <categorytree/> is invalid, but where encountered
the content of the tag is null.

Convert the null to empty string since CategoryTree::getTag require one

Bug: T378765
Change-Id: Iede4499952295b75a19bd05a5963caab00a9cadd
2024-11-01 12:41:17 +01:00
Fomafix 23ddd8cfd1 Remove unused parameter PPFrame $frame
Change-Id: Ic014850a01fbf5820c2ad77d89ae98e1525dcb7b
2024-10-27 04:42:31 +00:00
Andre Klapper 63688178e9 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: I40bb7a0a02aaa467cbf0ae182adf5601ccbcb58e
2024-10-26 14:43:49 +02:00
Umherirrender 113ece0e54 Use namespaced PPFrame class
Change-Id: I5fff88a0c944cfbda33ffcab1bb6a01e5440a52a
2024-10-19 23:22:14 +02:00
jenkins-bot 9399909bf3 Merge "Trigger CategoryTree::setHeaders only if subcategories available" 2024-10-10 16:45:10 +00:00
Fomafix 921e6fe3f9 Move all Parser handling to Hooks::parserHook
Change-Id: I5d35c6d87b610ffb566588a3d0c75067c1d06962
2024-10-04 19:55:24 +00:00
Fomafix a918bdea16 Remove $allowMissing and make the check directly on the hook
This change avoids a super category expand button on not existing
categories.

This change even avoids loading the modules if there are no valid
categories.

Change-Id: I38a2b49aaef7cf46d9f89e1cc9fd65e2382155f5
2024-10-04 19:53:37 +00:00
Fomafix f5f1f7de39 Use new hook OutputPageRenderCategoryLink
The new hook OutputPageRenderCategoryLink gets triggered on rendering a
single category.

This change prevents wgCategories = [] on
$wgCategoryTreeHijackPageCategories = true.

Bug: T372155
Depends-On: Id82a77a57d1f12233d974ea4c1b093f50c5ab74f
Change-Id: Ic86f210474cbc0e2dcebf664cf2309a4a4408f60
2024-09-03 09:50:34 +00:00
Fomafix 8fe224cd60 Use PHP types
* Add PHP type hints where possible.
* Remove @var, @param and @return if redundant to type declaration
* Remove redundant type conversions which are now enforced by type
  hints.
* Enforce that decodeBoolean returns only a bool.

Change-Id: I8da84ed4dc778dd9d84f8d9eec0a399f5ed26405
2024-08-20 08:16:37 +00:00
Umherirrender 3e2ce8c6f4 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I51931c3aab6aa1e5bc77b3cc83b8014cf557ff75
2024-06-08 23:29:21 +02:00
jenkins-bot b42252b37b Merge "Show a deprecation warning if parameter onlyroot is used" 2024-06-03 16:25:59 +00:00
Fomafix e6c9eab90f Use namespaced PHP classes
These namespaces are available since MediaWiki 1.42 which is already
required in extension.json.

Change-Id: If72d77a5440516beeac637b4baf06e9b4c672e8a
2024-05-22 20:11:23 +00:00
Fomafix 15a2d717d5 Show a deprecation warning if parameter onlyroot is used
The parameter onlyroot is deprecated since July 2008.

Generate a tracking category for tracking the deprecation.

Bug: T290062
Change-Id: I8eb58fa7831e11e6a6719f11fb1ff310666cdc4e
2024-05-20 07:49:47 +00:00
Fomafix 40f3638412 Trigger CategoryTree::setHeaders only if subcategories available
This avoids loading the modules if they are not needed.
Multiple calls of CategoryTree::setHeaders doesn't matter.

Change-Id: I96f8ffa7cf1d5274a6853403c0f2422b684db61f
2024-04-08 18:43:19 +00: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 8bd82c12f6 Use namespaced classes
Change-Id: I9fabf791aae691dfa7d071a1d99d17f4f7379682
2023-10-03 09:36:31 +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
Umherirrender 6e911fba75 Replace CategoryTreeCategoryViewer with hooks of CategoryViewer
Change-Id: I34a47c4f2f4b08cd3ed8ce5c4a585cc42d44372d
2023-02-28 23:20:56 +01: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 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
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 06dcae70b4 Get config values from Config instead of from global variables
Change-Id: I316b892ed01472fac75f72f50c820676fb3ce58a
2021-11-01 20:20:35 +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 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 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
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
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
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
Reedy 03685efdba Namespace extension
Change-Id: Idf4fbb9ff0c11b9da0b48b3843b2c87c155a4c36
2021-04-08 01:28:21 +01:00
Renamed from includes/CategoryTreeHooks.php (Browse further)