aboutsummaryrefslogtreecommitdiffstats
path: root/includes/site/Site.php
Commit message (Collapse)AuthorAgeFilesLines
* site: Streamline Site class using modern PHP featuresthiemowmde2024-07-181-16/+6
| | | | | | | I believe this makes such code much easier to read and less error-prone. Change-Id: I40023b28b934bc75d1217d23ad6ec181312db11e
* Fix various version mention for class_aliasUmherirrender2024-07-051-1/+1
| | | | | | | | Versions are changed in 8e940c4f214ff7d17b53f51c6a46a5cf7fc2c92e, but that makes the version wrong Follow-Up: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0 Change-Id: Iae43725b8e0fffc4d44bf57f6227334b41290bd9
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-191-3/+1
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Replace a few array_key_exists with the ??= syntaxthiemowmde2024-01-081-4/+0
| | | | | | | | Or just remove it. It's not needed when the structure is already an array. PHP will happily initialize multi-dimentional arrays when needed. Change-Id: I93845e8d6f870d147bd55cfe3827bc94b375d0ba
* Namespace Site and SiteListAmir Sarabadani2023-12-141-7/+14
| | | | | Bug: T353458 Change-Id: I31f7cba42c02701e462eb3ed6bcc3928d438c1ef
* Replace some usages of MWExceptionDaimona Eaytoy2023-01-261-27/+7
| | | | | | | | These exceptions are not documented with @throws and they're really not meant to be caught. Bug: T86704 Change-Id: I07f32e42c6fd4bc8785bac91547858f15a9fc2a8
* Merge "Various doc fixes about false on method arguments/return types"jenkins-bot2022-11-171-1/+1
|\
| * Various doc fixes about false on method arguments/return typesUmherirrender2022-11-101-1/+1
| | | | | | | | | | | | Doc-only changes Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
* | Remove pre PHP 7.4 serialize()/unserialize()Reedy2022-11-101-23/+1
|/ | | | | Depends-On: I3b893152ed278a72b5e74ccf91a3381f319bfcd9 Change-Id: I9f69a9316eaec23103262ec2ffd5b85baaf16f3f
* site: Switch new code from MWException to RuntimeExceptionTimo Tijhof2022-11-081-26/+7
| | | | | | | | | | | | Follows-up I5ed7e169c9753 (779df10d, T319219) which introduced a new use of MWException, as per T86704. While at it, also remove a few unhelpful `@throws` annotations that do nothing other than save an outdated IDE scan of what throw statements internally exist. These aren't meant to be caught and thus aren't of use to consumers of these docs as per T321683. Change-Id: I4ef964342de80eb2c1dec99cd6258727e6cd1a2c
* site: Annotate CachingSiteStore as `@internal` and perform minor cleanupTimo Tijhof2022-11-051-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | * Recognise CachingSiteStore as the internal class that it is. * Clean up the file header and move ingroup annotation, similar to other commits under <https://gerrit.wikimedia.org/r/q/message:ingroup+owner:Krinkle>. The one here was particularly odd as it placed the license inside the class doc block rather than the file doc block. * Remove unused $cacheKey and $cacheTimeout constructor args. They were also not covered by any unit tests. * Avoid use of `empty()` as per <https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP> * Use a more conventional cache key in CachingSiteStore, keeping the dynamic part for a later segment and keeping the first segment explicitly tied to a single concrete key group. This also improves ergonomics of cache statistics e.g. in Grafana and makes the cache key easier to locate in codesearch/grep, and more recognisable, e.g. starting with the code component ("site"). Change-Id: I541ad62551ab76127d70ef665272fd1d590ab556
* Fix Site::getPath() + MediaWikiSite::getFileUrl() confusionLucas Werkmeister2022-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Site::getPath() has returned null since change I08ffa6a970 (commit a00337c3f8), almost ten years ago; I think on the whole it’s safer to fix the prose documentation and keep the @return and actual returned value as they are, rather than the other way around. MediaWikiSite::getPageUrl() compared the $filePath to false instead of null, so the comparison would always be true; but on closer inspection, I think this code was supposed to check $path, not $filePath, in the first place. The only reason this didn’t come up so far is that all known callers pass in a custom path (specifically, all non-test callers pass in 'api.php'), so the $path = false default was never used. To avoid a deprecation warning in PHP 8.1 when passing a null $filePath into str_replace(), throw in that case instead – the function isn’t documented to return string|null, and none of the callers seem prepared to handle a null return as far as I can tell, so throwing seems better than returning null. Tests that produce a null $filePath need to be fixed to complete the Site object (compare Wikibase change If20688411e). Bug: T319219 Change-Id: I5ed7e169c9753486c765fd816d1b21016c5c1def Depends-On: If20688411e3f0108b0c0ba3b91e5cc264b70a208
* site: Consistently return null from Site::getDomain()Mark A. Hershberger2022-07-061-3/+9
| | | | | | | | | | | | | Note that null triggers the following for php 8.1: PHP Deprecated: strrev(): Passing null to parameter #1 ($string) of type string is deprecated Got a few of these in WikiMapTest::testMakeForeignLink(), caused by a single call in DBSiteStore. Bug: T289926 Change-Id: I0b29963ec0e2e8a38a66e250e81fbc16e42465ab
* Get rid of warnings on PHP 8.1Aryeh Gregor2022-06-131-2/+2
| | | | | | | | | | | This is mostly about adding return types to methods that implement PHP interfaces, and not passing null to core functions that want a string. After this patch, and an update to return types in RemexHtml, tests/phpunit/integration/ has no more errors than in PHP 8.0. Bug: T289879 Bug: T289926 Change-Id: Ia424f5cc897070f4188ae126b5bf6a1f552db0e1
* Use MainConfigNames instead of string literals, #3Aryeh Gregor2022-04-261-1/+3
| | | | | | | | | | | | | 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
* Implement __serialize/__unserialize for PHP 8.1 supportReedy2022-02-011-5/+22
| | | | | Bug: T299312 Change-Id: I8a758ed52b18d52cf083b645fbd88725cca983e8
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-3/+3
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Various updates and fixes to PHPDoc documentationThiemo Kreuz2021-08-091-2/+2
| | | | | | | Some minor updates I collected in my local dev environment the past months. Change-Id: I30d5339bc262d54ba76e2860a3a3e9e5f002fdc3
* Make following redirects in MediaWikiPageNameNormalizer optionalAmir Sarabadani2021-07-271-1/+5
| | | | | | | | If you want to normalize a page title without following the redirect, you basically have to re-invent the wheel. Let's DRY it this way. Bug: T278962 Change-Id: I61080ff0f35199784f4629f61272fb27bac787aa
* Use null coalecing operators everywhere consistenctly.Petr Pchelko2021-06-031-1/+1
| | | | | | Auto-generated with rector. Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
* Use ?? instead of isset/array_key_exists where possibleThiemo Kreuz2021-02-101-1/+1
| | | | | | | | | | | This patch touches all uncontroversial (I hope) places where a chain of isset(), array_key_exist() and the ternary ?: operator can be replaced with the much shorter ?? feature from PHP 7. ?? does the same. It checks if the element before the ?? is set and not null. When this check fails, the element after the ?? is used. Change-Id: Id612e2782ae928164b26b6f0de676c6c7d8302f3
* Fix more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-151-8/+8
| | | | Change-Id: I0ccda3d1de29b1044f74ef0972949eb8fbcb707d
* Remove usages of deprecated Language methodsPetr Pchelko2020-02-161-1/+7
| | | | Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
* site: Make getPageUrl consistently return nullDaimona Eaytoy2019-09-171-4/+4
| | | | | | | | This was pointed out in Ia8443e575c22f47a6d8c63038f4e7ac36815fc27. The method checks if $url is false, but that's never the case because getLinkPath returns string|null. Change-Id: I7850bff928f861d796879301ba0b4e575919407e
* Update docblocks for methods potentially returning nullDaimona Eaytoy2019-09-151-1/+1
| | | | | | | | | These were discovered by setting `null_casts_as_any_type` to true in phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there are others, some of which are false positives, but we cannot suppress them now (or the UnusedSuppressionPlugin will complain). Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27
* Unsuppress more phan issues (part 3)Daimona Eaytoy2019-08-311-1/+1
| | | | | | Bug: T231636 Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd Change-Id: I58e67c2b38389df874438deada4239510d21654f
* Site: Explicit allow setLanguageCode( null )Fomafix2019-03-121-2/+2
| | | | | | | | | | | $site->setLanguageCode( null ) is already used in DBSiteStore::loadSites and this worked because Language::isValidCode( null ) === true. This change explicit check for null and allow to set null without depending on Language::isValidCode( null ) === true. Change-Id: I0c9fe03cbf1434b0340e61e96360c0aaeb0fe89d
* Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errorsKunal Mehta2018-05-231-1/+1
| | | | Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
* Improve normalizePageName documentationLucas Werkmeister2018-04-111-2/+4
| | | | | | | | | Even though it wasn’t documented in the interface, MediaWikiPageNameNormalizer::normalizePageName returns false for pages that do not exist on the remote site. Too many users already depend on this feature to remove it, so at least document it properly. Change-Id: Ic2ba86b81bba86b868a6697aa57fdd46432c0d7d
* Fix (MediaWiki)Site::normalizePageName return typeThiemo Kreuz2018-04-081-1/+1
| | | | | | | | | I checked all callers of these methods and almost all of them expect the method to return false. It looks like this return type was known at some point, but got lost. Let's add it back. Bug: T191634 Change-Id: I43484835b8f26e07ada6a2b1452a99ccc6d9b438
* update mediawiki-codesniffer to 0.11.0 and fix issuesWMDE-Fisch2017-08-111-1/+1
| | | | | | | | - mostly auto fixes - some too long lines fixed - ignore amp space in one case passing by reference Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
* Remove auto-generated "Constructor" documentation on constructorsThiemo Mättig2017-07-101-2/+0
| | | | | | | | Having such comments is worse than not having them. They add zero information. But you must read the text to understand there is nothing you don't already know from the class and the method name. Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
* Add maintenance script to add sites to sites tableFlorian2017-02-261-0/+3
| | | | | | | Also: Add language code validation to Site::setLanguageCode(). Bug: T132937 Change-Id: I763ec65cb06d5250a3886a66eefdde8701b2299c
* Convert all array() syntax to []Kunal Mehta2016-02-171-11/+11
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Remove deprecated SiteObject and SiteArray classesaude2015-11-041-6/+0
| | | | | | | SiteObject and SiteArray were deprecated in 1.21 and can't find any use of them anywhere else in gerrit. Change-Id: Iff3ba8a60ac9566998cce828c4034066fdefe804
* Site: fix copy-n-paste phpdocBryan Davis2015-10-071-2/+2
| | | | Change-Id: I5e735089b3dacea94044fa96f821fc47940f7029
* Add since to @deprecated in includes/siteumherirrender2014-07-211-1/+1
| | | | | Follow-Up: I08ffa6a97093abbe85169f664b97498c5f39bf8e Change-Id: I6c3e607a4f095ca0dcd2f240c0c483b90c16c13d
* Pass phpcs-strict on includes/site/Siebrand Mazeland2014-05-091-9/+13
| | | | Change-Id: Ibc3f29e21dd5bcfd5ea641a58f8d3f641948741d
* Fixed some @params documentation (includes/*)umherirrender2014-04-191-4/+4
| | | | | | | | | Swapped some "$var type" to "type $var" or added missing types before the $var. Changed some other types to match the more common spelling. Makes beginning of some text in captial. Also added some missing @param. Change-Id: Iced714bca004756b461b66067a49a925a7e3b877
* fix some spacingumherirrender2013-03-071-1/+0
| | | | | | | | Added/removed spaces around logical/arithmetic operator Reduced multiple empty lines to one empty line Removed wrong tabs before comments at end of line Removed too many spaces in assigments Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
* remove space before semicolonumherirrender2013-02-091-1/+1
| | | | Change-Id: Ic0d890f5e27cec017c7f7910a67d53b2edf82079
* Merge "Fix cache key used by SiteSQLStore."jenkins-bot2013-01-241-1/+11
|\
| * Fix cache key used by SiteSQLStore.daniel2013-01-241-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | This makes sure that SiteSQLStore uses a cache key that includes information about the serialization structure as well as where the list of sites was loaded from. This avoids problems with loading "old" serialized versions from the cache after an upgrade. It also avoids cache conflicts with site lists loaded from different places. Change-Id: I7ad5b8ae63dc24598d41b2f150df7c14105d9f62
* | Implemented Serializable interface in Sitejeroendedauw2013-01-241-3/+49
|/ | | | Change-Id: I1d8394e0aa65e6ba16f1a1c1021bcae93ebb3e41
* Design improvements to sites codejeroendedauw2013-01-221-90/+421
| | | | Change-Id: I08ffa6a97093abbe85169f664b97498c5f39bf8e
* miscellaneous doxygen warningsAntoine Musso2012-10-221-1/+1
| | | | | | | | | | | | | * @licence -> @license * Protects inline HTML by using double quotes, our inline comments uses elements such as <h1> or <firstnameLastname@gmail.com> * Commands in lowercase (@TODO -> @todo, @NOTE -> @note) * removes @abstract and @static since doxygen detects them from PHP code. * various undocumented function parameters * typos in parameters declarations Change-Id: I62ad6fc124c355bf31acc780b9614a59cf79a421
* Update @since tags from 1.20 to 1.21jeroendedauw2012-10-121-27/+27
| | | | Change-Id: Iea7bad4367782ee8baa676921625b44dc2b7c45f
* Added sites functionality, a much more generic and flexible version of the ↵jeroendedauw2012-10-121-0/+316
existing interwiki code This code is meant to replace the current interwiki code, but does not do so just yet. It is however used by the Wikibase extension. This allows us to try out some more things and have the code stabilize more before we migrate over existing interwiki functionality. Change-Id: I23c47c2c3909a1500350fb560a5f2ec654e2c37e