aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/parser/MagicWordFactoryTest.php
Commit message (Collapse)AuthorAgeFilesLines
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Move Language and friends into Language namespaceJames D. Forrester2024-08-101-1/+1
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* tests: Namespace more parser classesReedy2024-02-171-0/+5
| | | | Change-Id: I35d6e3181ed885b8731ff1c4b5703459fb4223e4
* Deprecate MagicWordFactory::getSubstIDsthiemowmde2023-11-131-5/+5
| | | | | | | | | | | | | | | The main motivation is to further reduce the complexity of the class: * There is no code that ever writes to $this->mSubstIDs. It's effectively a constant. * According to CodeSearch the getSubstIDs() method is not used anywhere. It's @internal to the parser. * I find it weird that the parser needs to call 2 factory methods to do 1 thing. * I still find it a good idea to keep the knowledge encapsulated in the factory and not have the [ 'subst', 'safesubst' ] array in the parser. That's why I propose the new method. Change-Id: I5c147c75200c3c34a410d93a0328b56ea00a050f
* parser: deprecate unused MagicWord::getId, improve docs and testsTimo Tijhof2023-10-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * MagicWord::getId was added in r24808 (164bb322f2) but never used. At the time, access modifiers like 'private' were not yet in use. Deprecate the method with warnings, for removal in a future release. * Fix zero coverage for MagicWord, due to constructor being internal, this is only intended to be created via array and factory classes. Let their tests cover this class. * Remove redundant file-level description and ensure the class desc and ingroup tag are on the class block instead. Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+message:ingroup * Mark constructor `@internal` (was already implied by stable interface policy), and explain where to get the object instead. * Mark load() `@internal`. Method was introduced in 1.1 when the class (and PHP) did not yet use visibility modifiers for private methods. The only way to get an instance of MagicWord (MagicWordFactory::get) already calls load(), the method is not a no-op if called a second time, and (fortunately) there exist no callers to this outside this class that I could find. * MagicWordArray::getBaseRegex was marked as internal in change I17f1b7207db8d2203c904508f3ab8a64b68736a8. Change-Id: I4084f858bb356029c142fbdb699f91cf0d6ec56f
* parser: Use more specific exceptions in MagicWord classesthiemowmde2023-10-251-1/+1
| | | | | | | | | | | … instead of the generic MWException and even more generic Exception. Most, if not all of these should be unreachable anyway. I.e. these are what we call "unchecked" exceptions, see T240672. We also have a polyfill for preg_last_error_msg. No need to wrap it in a function_exists (any more). Change-Id: Ie26bef3b4371d011ec3f1874986072605692f486
* parser: improve cache TTL accuracy for CURRENT*/LOCAL* magic wordsAaron Schulz2023-03-281-16/+0
| | | | | | | | | | | | | | | | | | | Consolidate cache TTL handling within CoreMagicVariables. Make the TTL account for how many seconds away the value is from changing. For example, CURRENTHOUR should change soon after the next hour is reached. There is a minimum adjustment TTL to avoid parser-after-save delays. This allows for longer caching in most cases, as well as more up-to-date rendering when the hour/day/week/year is about to change. Previously, there were blind TTLs, which are either way too pessimistic or way too generous. This commit does not change the CURRENTTIME, CURRENTTIMESTAMP, LOCALTIME, and LOCALTIMESTAMP words, since there is no reasonable way to cache output while keeping them up-to-date. Bug: T320668 Change-Id: I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f
* Reorg: Move MagicWord related files to under parser/Amir Sarabadani2022-12-091-0/+87
This is approved as part of T166010 RFC. Bug: T321882 Change-Id: Ia4498c0a20e38a6a288dc14065ea8242c84fbc49