aboutsummaryrefslogtreecommitdiffstats
path: root/includes/title/NamespaceInfo.php
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-251-1/+1
| | | | | | | | | In MediaWiki/Exception, to follow PSR-4 per plural vs. singular (this can be changed later if people really care). Also, move the couple of exceptions in here that were already namespaced in the MW-top-level into the new space. Bug: T353458 Change-Id: I12ed850ae99effb699a6d7ada173f54e72f0570e
* title: Use const for NamespaceInfo::$alwaysCapitalizedNamespacesUmherirrender2024-09-011-2/+2
| | | | Change-Id: I29bc609c5148668e533a9ed9f72b29f780f00dba
* Replace gettype() with get_debug_type() in exception messagesBartosz Dziewoński2024-07-311-1/+1
| | | | | | | | | | | | | | | | | | | get_debug_type() does the same thing but better (spelling type names in the same way as in type declarations, and including names of object classes and resource types). It was added in PHP 8, but the symfony/polyfill-php80 package provides it while we still support 7.4. Also remove uses of get_class() and get_resource_type() where the new method already provides the same information. For reference: https://www.php.net/manual/en/function.get-debug-type.php https://www.php.net/manual/en/function.gettype.php To keep this safe and simple to review, I'm only changing cases where the type is immediately used in an exception message. Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
* Use real type hints for services etc. in includes/title/Bartosz Dziewoński2024-07-311-13/+2
| | | | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 More could be done, but to keep this patch reasonably sized, I only changed the most obvious and unambiguously correct cases. In some cases, I also removed redundant doc comments on the constructor, and re-ordered the properties to match the constructor. Change-Id: Ibcb81c7ecdbc24820c76d159d50e2f79c7c4c656
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-191-4/+1
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Avoid implicit type cast to boolean in isTalkFomafix2023-11-241-1/+1
| | | | | | | | | In PHP `true && 1` evals to `true`. In JavaScript `true && 1` evals to `1`. The convert to a boolean by !!() in JavaScript is not needed anymore. Change-Id: Ie2ff2ef3aa9c5ada82fb2820992d17128fa2fbff
* Namespace NamespaceInfo under \MediaWiki\TitleJames D. Forrester2023-09-191-1/+10
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
* Namespace TitleValue under \MediaWiki\TitleJames D. Forrester2023-09-181-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
* Inject extension namespaces into NamespaceInfoDaimona Eaytoy2023-07-161-8/+17
| | | | | | | | | | The service was previously accessing the global ExtensionRegistry singleton, making it lose its statelessness. Dependencies should always be injected, so add constructor parameters for that. Simplify tests accordingly. Change-Id: Iae375a81cab411fab607cba0addb2088131b3c81
* Replace array_keys in foreach to use $_ as value insteadUmherirrender2023-07-101-1/+1
| | | | | | | | When the value of the associated array is not used, there is no need to use array_keys and create internal a copy of the array, just omit the value with $_ to tell static analyzer that the var is unused. Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
* Collapse sequences of `if` into short `return` if possiblethiemowmde2023-06-151-9/+3
| | | | | | | The main goal is to make this code faster and easier to read, and to avoid duplication. Change-Id: I925d742d560e9d90e3ecc9ff19fe7e87b60bf9a4
* Remove NamespaceInfo::getRestrictionLevelsMatěj Suchánek2023-05-201-20/+0
| | | | | | It has been deprecated since 1.34 and it is unused. Change-Id: Icd9b33a8c4051505e16aad384ebb509aa5e18649
* Various doc fixes about false on method arguments/return typesUmherirrender2022-11-101-1/+1
| | | | | | Doc-only changes Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
* Use MainConfigNames instead of string literals, #3Aryeh Gregor2022-04-261-11/+12
| | | | | | | | | | | | | This edition brought to you by: grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr "\n" '|' | sed 's/|$/\n/') includes/ I only corrected a fraction of the results provided by that command. I'm submitting the partial patch now so it doesn't bitrot. Bug: T305805 Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
* Generate config name constants.daniel2022-03-181-9/+10
| | | | | | | | | We can generate a class that contains constants for all config variable names. This removes the need to rely on string literals when calling Config::get, and it provides a place for documentation that integrates better with IDEs than the markdown file. Change-Id: I817dc14c4ce8fc0a29d9c07e8fd393c4f359cade
* Make some generic array type hints in PHPDocs more specificThiemo Kreuz2021-12-081-1/+1
| | | | | | | | | | | This patch focusses on permission related stuff. "Policies" is particularly confusing in this patch. In some cases the word refers to a list of policies (one such policy being e.g. "minimum password length = 8 characters"). But sometimes it's a list of lists of such policies, keyed by user group. Change-Id: I0346e59c7b79839114dd0d0bc7ee38289c1b06a1
* build: Updating dependencieslibraryupgrader2021-07-221-3/+3
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* registry: Allow specifying immovable namespaces in extension.jsonAmmarpad2021-03-171-1/+4
| | | | | | | | In most cases this will alleviate the need to use the ImmovableNamespaces hook. Bug: T277520 Change-Id: If1e1063a597ebdb39343a356cc381a6ceafaebcc
* Clarify uses of NamespaceInfo::hasSubpages in documentationThalia2020-12-041-1/+2
| | | | | | | Clarify that this method does not refer to SpecialPage subpage parameters. Change-Id: Ief54be2e83d4b09b265754849db487923d872939
* Hard deprecate NamespaceInfo::getRestrictionLevelsAmmar Abdulhamid2020-11-161-0/+1
| | | | | | It's overdue and appears unused Change-Id: I5d7f4a52b3258b2e711792ac0f5487f0b44c92a6
* Update a lot of unspecific "array" types in PHPDocsThiemo Kreuz2020-10-281-3/+3
| | | | | | | | | This includes fixing some mistakes, as well as removing redundant text that doesn't add new information, either because it literally repeats what the code already says, or is actually duplicated. Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
* Fix typos related to repeated wordsUmherirrender2020-09-271-1/+1
| | | | Change-Id: Ibc187d95b003017255bc87adf56afae7a59bd3db
* Remove $wgAllowImageMoving, deprecatedDannyS7122020-09-141-8/+1
| | | | | Bug: T245293 Change-Id: I4026eda0d072426112040c5c74cc6e14382b7681
* Mark CONSTRUCTOR_OPTIONS as internalAryeh Gregor2020-08-211-2/+1
| | | | | | | | These were never meant to be part of the public interface and should not ever have been marked with @since. They're only useful for constructing the respective objects, which no outside users should be doing. Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
* Introduce wfDeprecatedMsg()Tim Starling2020-06-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Deprecating something means to say something nasty about it, or to draw its character into question. For example, "this function is lazy and good for nothing". Deprecatory remarks by a developer are generally taken as a warning that violence will soon be done against the function in question. Other developers are thus warned to avoid associating with the deprecated function. However, since wfDeprecated() was introduced, it has become obvious that the targets of deprecation are not limited to functions. Developers can deprecate literally anything: a parameter, a return value, a file format, Mondays, the concept of being, etc. wfDeprecated() requires every deprecatory statement to begin with "use of", leading to some awkward sentences. For example, one might say: "Use of your mouth to cough without it being covered by your arm is deprecated since 2020." So, introduce wfDeprecatedMsg(), which allows deprecation messages to be specified in plain text, with the caller description being optionally appended. Migrate incorrect or gramatically awkward uses of wfDeprecated() to wfDeprecatedMsg(). Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
* NamespaceInfo::makeValidNamespace: Don't throw for -1 or -2James D. Forrester2020-06-101-1/+7
| | | | | Bug: T253098 Change-Id: Ifa5a3d587fe8298d356f513bcbf2a432cc70712b
* Merge "Deprecate setting `$wgAllowImageMoving` to false"jenkins-bot2020-06-091-0/+4
|\
| * Deprecate setting `$wgAllowImageMoving` to falseDannyS7122020-06-061-0/+4
| | | | | | | | | | | | | | | | Trigger deprecation warnings in NamespaceInfo::isMovable, where it is used Bug: T245293 Change-Id: Iec8b60ae97e390e7aa88ae2e8fbeb234e728d9d9
* | NamespaceInfo: Throw specifically if called on a non-int/non-int-like namespaceJames D. Forrester2020-06-031-0/+25
|/ | | | | | | | | Mostly just for debugging purposes; later we can enforce this with a type hint, but first I want to track down the uses. Bug: T253098 Depends-On: Ieecbc91a8f26076775149a96fbe1b19a7f39dcef Change-Id: I66ea07f1acf6db2d13de488b775361f45b69020c
* Hooks::run() call site migrationTim Starling2020-05-301-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* NamespaceInfo: use array constants now that we canMax Semenik2019-10-051-12/+5
| | | | Change-Id: I676a68fdc42ff2f37c7e4a2700b7c0c448155d47
* Merge "Add NS_MAIN to NamespaceInfo::$canonicalNames"jenkins-bot2019-09-041-0/+1
|\
| * Add NS_MAIN to NamespaceInfo::$canonicalNamesDavid Barratt2019-09-041-0/+1
| | | | | | | | | | | | | | The main namespace is missing from the list of canonical names. Bug: T232004 Change-Id: I2ec9af3ba657d87d3a0eb7febafb3ca4eb7c59ac
* | Upgrade phan config to 0.7.1Daimona Eaytoy2019-09-041-1/+2
|/ | | | | | | | This allows us to remove many suppressions for phan false positives. Bug: T231636 Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065 Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
* Move getRestrictionLevels from NamespaceInfo to PermissionManager.Petr Pchelko2019-08-221-73/+8
| | | | | Bug: T11977 Change-Id: I051be9148c98086fdf53a66a74bf7c28699016db
* Move list of core namespaces to NamespaceInfoDavid Barratt2019-08-081-0/+39
| | | | | | | | It is sometimes necessary to get an unmodified list of namespaces that are in core. Bug: T226657 Change-Id: I8e4ed19db915a1673c27ca5b212d712d079b4bba
* Ensure canHaveTalkPage returns false when getTalkPage would fail.daniel2019-07-031-4/+51
| | | | | | | | | | This causes Title::getTalkPage and NamespaceInfo::getTitle() to throw an MWException when called on a LinkTarget that is an interwiki link or a relative section link. These methods were already throwing MWException when called on a link to a Special page. Bug: T224814 Change-Id: I525c186a5b8b8fc22bca195da48afead3bfbd402
* Fix logic in NamespaceInfo::getRestrictionLevelsAryeh Gregor2019-05-091-11/+23
| | | | | | | | | | When $wgNamespaceProtection specifies multiple rights for a namespace, the code was assuming all of those rights had to come from one group. But MediaWiki allows for the rights to come from multiple groups that each give a subset of the rights. Allow for that case. Bug: T222598 Change-Id: I1e9aca6e521260f783bd881e7d095d62bc605dc6
* Move Title::getSubject/Talk/OtherPage to NamespaceInfoAryeh Gregor2019-05-061-0/+36
| | | | | | This allows converting some more code to LinkTarget. 100% test coverage. Change-Id: I28903af6a41d02755f37f31561a524547445821e
* 100% test coverage for NamespaceInfoAryeh Gregor2019-05-061-10/+10
| | | | | | | | | | | | | In the new tests I added, I tried to cover all interesting scenarios and not just hit each line to make the coverage green. But I didn't review all the existing tests to see if they were properly thorough, so there might still be room for improvement. I uncovered a bug here that will be addressed in a separate commit, because the fix is not so simple. For now I left the test expectation as a @todo. Change-Id: I33d556bf83c631a8a02a6c77f2f5cb06b8dbf869
* Don't pass Config to NamespaceInfoAryeh Gregor2019-05-061-21/+45
| | | | Change-Id: Ie43e6108c6b9bcb666b1dece055e0df689e2ec42
* Fix docs for MWNamespace::clearCaches() removalAryeh Gregor2019-04-111-1/+1
| | | | | | | | | | | | | | Originally I had intended setMwGlobals() to magically reset the namespace-related services if namespace-related settings were changed, but Tim told me to remove it during review and I forgot to update the release notes. Moving forward, everyone will need to reset services after every config change to ensure correctness, and there's no point in trying to reset specific services automatically as special cases. I also moved the note to the 1.34 notes, since this missed the cutoff and should not be backported. Change-Id: Ib7cbdaef22a15ddfc7aaf99d0972b99d3cddc011
* NamespaceInfo service to replace MWNamespaceAryeh Gregor2019-04-101-0/+526
MWNamespace::clearCaches() has been removed entirely, along with the $rebuild parameter to MWNamespace::getCanonicalNamespaces(). The rest of MWNamespace is deprecated. Diff best viewed with -C1 so git notices that NamespaceInfo is a copy of MWNamespace. Depends-On: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d Depends-On: Ib3c914fc99394e4876ac9fe27317a1eafa2ff69e Change-Id: I1a03d4e146f5414ae73c7d1a5807c873323e8abc