aboutsummaryrefslogtreecommitdiffstats
path: root/.phan
Commit message (Collapse)AuthorAgeFilesLines
* Introduce minimal OTEL tracing libraryMáté Szabó2024-10-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | In T340552, the official PHP OpenTelemetry client was effectively rejected for inclusion in MediaWiki due to its size. Implement a minimal tracing library instead that eschews conformance with the OTEL client specification in favor of simplicity, while remaining capable of emitting trace data in OTLP format and thus retaining compatibility with any ingestion endpoint capable of handling OTLP. In its current state, the library supports a basic feature set that should be sufficient for basic tracing integration: * Span creation, inclusive span activation and automatic parent span assignment, * Span attributes and span kinds, * Basic resource (process/request)-level metadata generation, * Data export over OTLP. Additional functionality, such as trace propagation, can then be incrementally added to the library. Bug: T340552 Change-Id: Ibc3910058cd7ed064cad293a3cdc091344e66b86
* Alias Parsoid DOM nodes to PHP DOM implementationC. Scott Ananian2024-05-222-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parsoid abstracts the specific DOM implementation it is using, in practice (currently) using subclasses of the built-in \DOMDocument classes using the \DOMDocument::registerNodeClass() mechanism. Parsoid's own phan configuration uses stubs for its abstract DOM classes to encourage the use of "standard" DOM methods -- but core doesn't use Parsoid's phan configuration and doesn't really understand the way that ::registerNodeClass() works and so get confused by code such as: $el = $document->createElement('div'); In actual practice this is a Wikimedia\Parsoid\DOM\Document (a subclass of \DOMDocument) which creates a Wikimedia\Parsoid\DOM\Element (a subclass of \DOMElement) via the ::registerNodeClass() mechanism, but phan sees only the base \DOMDocument::createElement() signature and assumes this creates a \DOMElement *not* a Wikimedia\Parsoid\DOM\Element. If you do "element-y" things on this, phan has no complaints, but if you pass this back to a Parsoid method which expects the abstract Wikimedia\Parsoid\DOM\Element type then phan (spuriously) complains. This type error can be hard to understand. Workaround this issue by simply aliasing Parsoid's abstract DOM types to the built-in \DOMDocument etc types. The alternative would be to use Parsoid's stubs, but it seems cleaner (for now) to avoid reaching into vendor/wikimedia/parsoid/.phan/stubs to get them. Change-Id: I90b33c5d65bde1582be9a452a144808b6d53d914
* build: Fix line indentsUmherirrender2024-03-111-2/+2
| | | | | | | Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of arrays for parameters is wrong Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
* ResourceLoader: Remove libs/jsminplus.php (JSMinPlus, JSParser)Timo Tijhof2024-01-191-2/+0
| | | | | | | No longer used. Bug: T75714 Change-Id: I2b097671716fabec169bc803da98cd0340d70cc4
* GlobalFunctions: Minor clean up of wfMkdirParents()Timo Tijhof2023-10-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | * Remove docs for unchecked exception (T321683). * Remove use of MWException, prefer more specific type (T86704). * Remove use of AtEase (T253461). * Merge `is_dir||mkdir||is_dir` into one check to more clearly express that our success criteria is explicitly one or the other, with a repeat for race conditions. This makes them not seem like unrelated checks or early returns, rather than the main code. This also fixes the seemingly unintentional difference where one check was before normalized $dir and one after. * Use native trigger_error() directly as does not add value to use MWDebug::warning() with merely the default parameters. The last edge case was $wgDebugToolbar which got fixed with I62d864823ec8a. Change-Id: Ic44798299a64f902decbc4cf2dbf2206a96c3837
* Merge "Add tests for taint-check"jenkins-bot2023-09-251-0/+1
|\
| * Add tests for taint-checkDaimona Eaytoy2023-09-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure that taint-check knows about these methods, especially as we move the taintedness info from the plugin to annotations on the methods. Some tests are currently disabled because they would fail. These will be enabled in subsequent commits while adding annotations to the relevant methods. Note that the disabling needs to be done by making the suppression annotation invalid (done by prepending 'xxx' in this patch), because commenting out the code or adding a method-wide @suppress won't work. Bug: T321806 Change-Id: I8b89a22a5c23a2ab25329bcb06c673168d24683d
* | Merge "phan: Re-enable class_alias support"jenkins-bot2023-09-251-3/+4
|\|
| * phan: Re-enable class_alias supportDaimona Eaytoy2023-09-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was disabled in I51dca12be9c77049f77563d9bf0edd07928c2300. The rationale is still valid; however, without class_alias support we cannot add tests for taint-check to verify that it knows about both the old and the new class names. The benefits of being able to test taint-check would currently outweigh the benefits of not using aliased classes. Set enable_class_alias_support to true again, but add a TODO comment that this should ideally be switched back to false if we can do that without breaking taint-check tests. Bug: T321806 Change-Id: I4177c7578cd84ce28d4ca359f73f89b6899bda68
* | Update references to config-vars.phpDannyS7122023-09-231-2/+0
|/ | | | | | | | Moved to docs/ rather than includes/, update references and remove from phan exclusion list Follow-up: I32c034d05bf2354cdaa5f02d19031421cbae78a1 Change-Id: I8d71c29c8cbfa413db47066f00d71783259f0916
* Add $wgRequest to phan's globals_type_mapDaimona Eaytoy2023-09-111-2/+3
| | | | | | | | | | | The base phan config uses a file_exists check to determine whether to use the namespaced class name, but it doesn't work when running against core because MW_INSTALL_PATH isn't set. So specify the type in the local config, and remove @phan-var annotations added in I6bbdbbe6. Also use `::class` instead of string literals for classes. Change-Id: I994a0ed32ea948253ed07ee3cc8868a0eaa6d8b9
* Reorg: Move three output related classes to includes/Output/Amir Sarabadani2023-09-051-1/+1
| | | | | | | | | | And namesapce them: - StreamFile - OutputHandler - OutputPage Bug: T321882 Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
* Merge "Add support for wikidiff2_multi_format_diff()"jenkins-bot2023-07-311-0/+9
|\
| * Add support for wikidiff2_multi_format_diff()Tim Starling2023-07-191-0/+9
| | | | | | | | | | Bug: T341754 Change-Id: I17396985d0b26516a06df17e9bd1343054521e01
* | tests: Update Phan stub to php-excimer 1.1.1Timo Tijhof2023-07-243-96/+65
|/ | | | | | | | | Last updated for php-excimer 1.0.4, which is missing getSpeedscopeData(), as used by excimer-ui-client and in examples on mediawiki.org. Bug: T266626 Change-Id: I7f0c86f83cbe3b0378648003a66fcb86da8d7828
* Revert "build: Add phan stub for ReturnTypeWillChange"Kevin Israel2023-05-162-7/+0
| | | | | | | | | No longer needed since 5ceaf8a5d45ba868, which added the symfony/polyfill-php81 requirement to composer.json. This reverts commit 7534655922f15f961910aadb41bbe58d2fce1039. Change-Id: I860f11180fe26c4626c467bdd298013236d70ad1
* objectcache: Remove $wgMainWANCache and $wgWANObjectCachesTimo Tijhof2023-03-071-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We always wrap the local cluster cache, and there are no subclasses of WANObjectCache. It was never documented or recommended how these would be used. It is a left-over from the original 2015 Multi-DC plan in which WANObjectCache would work differently. See task for details. Note that this requires no configuration changes, even in the theoretical case of these variables being used, as the only option is to use the main cache, and that's also the default. * Update WAN overrides to override the underlying main cache instead. * Fix EditPageTest which was previously implicitly using a 'hash' as main cache but also relying on wan cache to be 'none'. The part that it actually needs is the 'none'. When WAN cache is enabled, testUpdateNoMinor fails due to an edit conflict because one of the edits it makes is made with a current timestamp whereas it expects to simulate wpEdittime in the year 2012 which, when caching is enabled, is ignored and becomes the current time instead. I don't understand exactly why, but I'm going to conserve that behaviour for now. * Fix TemplateCategoriesTest, which was failing due to an unexpected cache hit: > [objectcache] fetchOrRegenerate(…:page:10:…): volatile hit This could be solved in a more realistic way by splitting the test, or by explicitly resetting services half-way the test to clear WikiPageFactory, PageStore and WANCache process state. For now, keep the prior behaviour of no cache in this test. Bug: T305093 Bug: T329680 Depends-On: If890622eed0d0f8b4bd73d36ba1815a3d760ea05 Depends-On: Ie1def75208822bdf19bb2cfd7e6edf32c2000e6b Depends-On: I35cce61dc3ee90dcee3dd6f0b36f84133be029ed Change-Id: I53781a8c06ebb2583f6ca83dd91bbfe8a5c88b13
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* TempFSFile: Use a WeakMap for reference tracking if availableMáté Szabó2023-02-122-0/+25
| | | | | | | | | | | | | Use a WeakMap to track references to TempFSFile instances if available to avoid deprecation warnings for dynamic property creation on PHP 8.2. Use an anonymous class rather than an stdClass to test the behavior in TempFSFileTestTrait to verify that bind() does not trigger dynamic property creation on PHP 8.2. Also add a Phan stub for WeakMap for PHP 7.4. Bug: T324894 Change-Id: Ic413c115e9ed1c750e175152094f3309628e777a
* build: Add phan stub for ReturnTypeWillChangeUmherirrender2022-12-162-0/+7
| | | | | | | ReturnTypeWillChange is new in php8.1 Allow to run phan under php80 with a stub Change-Id: Ib84b314bf495634583b625ed8d7530908286e839
* phan: Don't analyze .inc files, we don't use them nowKevin Israel2022-12-041-9/+0
| | | | | | | | | Also remove two vendor/* entries from exclude_file_list; besides the fact that one is a .inc file, both are part of dev dependencies, which are ignored after 3253cbf8d5e1826f. Bug: T184782 Change-Id: I0e0fac176b1c085e106533bcf3e8e3dcc75cd65a
* profiler: Drop support for Tideways 4.x in ProfilerXhprofKevin Israel2022-11-283-29/+16
| | | | | | | | | | | | | This branch fails to compile against PHP 7.4.3, our lowest supported version, and will not be updated to support that or any newer version: https://tideways.com/profiler/blog/releasing-new-tideways-xhprof-extension In doing so, remove the Xhprof class. At this point, it doesn't do anything other than calling either of two functions from whichever extension is installed, which can just be done in ProfilerXhprof. Change-Id: Iba1c16f47c68b36982f5d2dcda3bdf4dcb83501d
* phan: Remove internal stubs that should never be usedKevin Israel2022-11-254-1288/+0
| | | | | | | | | * dom: This PHP extension is an installation requirement so should always be available. * oci8: Oracle support was removed in 1.34 (4d10bb14e81aadb9). * sqlsrv: Likewise for Microsoft SQL Server. Change-Id: Id53f4ce477a19cff0063d3d60a405647249e7202
* phan: Remove ValueError stubKevin Israel2022-11-252-7/+0
| | | | | | | | | The only reference to ValueError (added in a80631ea0ca8ad6a) was removed in 47241a3520d5b4bf. Regardless, the stub is redundant to the one that is part of the symfony/polyfill-php80 library, which is already listed in composer.json as a required dependency. Change-Id: Ic9aa3e36d24bf79fb21ab37dd177e28f8176f573
* UserMailer: Don't check if PEAR Mail and Mail_mime classes existKevin Israel2022-11-252-95/+0
| | | | | | | | | | Since ee5a9b788a2fa3d9, pear/mail and pear/mail_mime are installed by Composer along with the other required external libraries, so these classes should exist in all installations. Also removed the Phan stub for the same reason. Change-Id: I6e545bf9fab15a66d1ea7bdf697908e7b1066897
* password: Update Argon2Password for PHP 7.4 minimumTim Starling2022-11-222-11/+0
| | | | | | | | | | | | | In PHP 7.4, it's possible to compile password without Argon, but if Argon is compiled in, both algorithms should be available. So: * Remove Phan stubs * Simplify class code * Add test per todo Change-Id: I749d456ad59698e5b1538b127586ea796efba1d1
* Phan: parse only directly required composer dependenciesTim Starling2022-11-101-2/+42
| | | | | | | | | | | | | | | | | | | Indirect dependencies are typically needed only by the direct dependencies, which are not analyzed. Dev dependencies are needed to run Phan, but are not needed in the code Phan is analyzing. So it turns out to be fairly straightforward to eliminate unnecessary dependencies from the Phan parse stage, reducing memory usage by about 40% and time usage by about 20%. This means I can run Phan on my laptop without first closing PHPStorm, which is convenient. As a matter of policy, you could argue that the list of allowed indirect dependencies here should be explicitly declared by moving them to composer.json. Change-Id: I987c3b22bafd1b4332fdeaf40ec3e20d35a3d929
* Respond to some messages from Phan on PHP 8.1Tim Starling2022-11-033-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ForkController, OrderedStreamingForkController: indeed pcntl_fork() can't return false. * RL\Image: Specify type instead of using suppression, since the issue name changes. * VueComponentParser: Accept complaint about nullable nodeValue. * Disable PHP 8.0 polyfill stubs when running on PHP 8.0+ to avoid duplicate interface errors. * Add Socket stub and use it in LegacyHandler instead of multiple existing suppressions. * MemcachedPeclBagOStuff: accept complaint recommending !$result over $result === false when the type is boolean. * MemcachedPeclBagOStuff: fix probable bug, ignoring errors from Memcached::getMulti(). Phan noticed that $res=false was unreachable, but it should probably be reachable. * DatabaseMysqli: accept complaint that $this->conn->errno is already known to be an int. It was probably a hack for some previous version of Phan. * BcryptPassword, MWOldPassword, MWSaltedPassword: accept complaint that the !is_string() checks are unnecessary, after code review of PHP. * Pbkdf2PasswordUsingHashExtension: note that contrary to Phan's suggestion, this check is necessary. * DefaultPreferencesFactory: remove an existing hack for array_diff_key(), no longer necessary on 7.4 and causes an error on 8.1. Use coalesce instead of cast for the remaining array_intersect_key() hack since it better shows that we are casting away null. * FullSearchResultWidget: fix likely bug involving strict comparison between a float and an int. * SpecialWatchlist: accept complaint that $selectedHours is unconditionally a float, being the return value of round(), and thus the cast is unnecessary. * Add stub for AllowDynamicProperties, resolving an error in User.php. * Xml: accept complaint that $encMonth is already known to be an int. Six errors remain. These need suppressions or otherwise conflict with PHP 7.4 support. Bug: T322278 Change-Id: Ie375bbc8ccf22330b9a169e8da98f2bbe26ec8b9
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-1/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+1
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* phan: Remove local override of suppress_issue_typesKevin Israel2022-10-211-7/+0
| | | | | | | | This is not needed after ef8c6b086e2c9399 in mediawiki/tools/phan, and the "approximate error count" in the comment is out of date after 43a93d9782bee485. Change-Id: I9c6749c981140227296e592f857f095bfb4ed29f
* .phan/config.php: Update minimum_target_php_versionReedy2022-10-031-3/+10
| | | | | | | Temporarily disable PhanPluginDuplicateExpressionAssignmentOperation Bug: T319186 Change-Id: I8ae3f74f482b5de3dd74471c2e853386d1fe1091
* Drop support for doctrine/dbal < 3.0.0Amir Sarabadani2022-09-291-12/+0
| | | | | | | Removes various hacks and back compat support Bug: T270740 Change-Id: I17d74705cdd5a2e1af0bda66bfa466067b8387a8
* Suppress php 7.4 phan false positiveZabe2022-09-191-0/+12
| | | | | | | | | | | | | | | see T298571 This failure only shows up for php 7.4 since that is using dbal 3.x.x while php 7.2 is using dbal 2.x.x Phan analysis is being disabled for those files for php 7.2 since those are now failing with 'unused suppression' and php 7.2 support is going to be dropped in the near future, so that doesn't matter to much. Bug: T316518 Change-Id: I74da37dc4329a7dd2c015a9d1fc7037a866f40c9
* tests/parser: Run phanUmherirrender2022-06-021-0/+6
| | | | | | | | | Run phan over classes in tests/parser The dependency of classes between parser and phpunit is not clear. Classes used by both possible needs part of /common/ Change-Id: I2ceca6b7cd447876c127ed3b14e09f479defbd93
* Docs: remove references to DefaultSettings.phpdaniel2022-05-301-3/+4
| | | | | Bug: T300129 Change-Id: I1e83a0dde6235bed91d28d7d43691c6a5d979f2f
* Turn DefaultSettings.php into a deprecated stubdaniel2022-05-171-0/+2
| | | | | | | | | | | DefaultSettings.php has been replaced by MainConfigSchema. Loading DefaultSettings.php is deprecated. Code that needs to have access to configuration defaults should use the ConfigSchema service object. Bug: T300129 Change-Id: I7b2c0ca95a78990be1cdb9dd9ace92f6dcf1af15
* phan: Add internal stub Redis::SERIALIZER_IGBINARYSébastien Beyou2022-04-181-0/+2
| | | | | Bug: T282133 Change-Id: I31f52d26bc022c77e50db42ac80c7dbe1a37c8e6
* phan: Remove PhanCompatibleAccessMethodOnTraitDefinition suppressionUmherirrender2022-03-311-3/+0
| | | | | | | | | | * Remove the fallback code in ImagePage, it is possible to call getImageLimitsFromOption non-statically in this situation * In OutputPage replace the call to trait function to one class implementing the trait Bug: T289813 Change-Id: I166a53615fb2be6e3d8b48489ce342e48435dfc3
* phan: Remove PhanPossiblyUndeclaredVariable suppressionUmherirrender2022-03-301-1/+0
| | | | | | | | | Make phan stricter about conditional variable declaration Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T259172 Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
* Merge "phan: Upgrade mediawiki-phan-config to 0.11.1 and set ↵jenkins-bot2022-03-291-0/+5
|\ | | | | | | minimum_target_php_version"
| * phan: Upgrade mediawiki-phan-config to 0.11.1 and set minimum_target_php_versionJames D. Forrester2022-03-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MediaWiki still supports PHP 7.2+, but we want to mainly test in newer versions of PHP. Setting minimum_target_php_version to 7.2 this lets us run phan without phan trying to get us to make PHP 7.2-incompatible changes to 'appease' PHP 8.0 or whatever later changes. Some switches of generic 'resource' type-hinting to 'resource|object' to inform phan to ignore this (triggering PHPCS at the time, ah well), rather than trying to hint the specific novel PHP encapsulation classes to that have replaced them from PHP 8.0 onwards but don't yet exist, and fixes from where we were checking the results of implode and explode. Bug: T293924 Change-Id: I629e3fb3adfad73beb3d424a07e643c2e079d9bb
* | phan: Remove PhanTypePossiblyInvalidDimOffset suppressionUmherirrender2022-03-281-1/+0
|/ | | | | | | | | | | Make phan stricter about array keys Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T304887 Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1 Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385 Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-1/+0
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* phan: Disable scalar_implicit_cast settingUmherirrender2022-03-181-2/+1
| | | | | | | | | Make phan stricter about scalar types by setting scalar_implicit_cast to false (the default in mediawiki-phan-config) Bug: T242536 Bug: T301991 Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
* Using @return never documentation on always-throw-functionUmherirrender2021-09-071-3/+0
| | | | | | | | | | This helps phan to detect unreachable code and also impossible types after the functions. It helps phan to avoid false positives for array keys when the keys are checked before Bug: T240141 Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
* build: Update mediawiki/mediawiki-phan-config to 0.11.0Umherirrender2021-09-071-2/+3
| | | | | | | Addition and remove of suppression needs to be done with the version update. Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
* build: Enable phan plugin UseReturnValuePluginUmherirrender2021-08-261-0/+3
| | | | | | | Suppress false positives Bug: T240141 Change-Id: Ie356512ad76de465b1fda5b913fa30702339cb11
* Bump wikimedia/remex-html to 2.3.2 and drop 2.3.1C. Scott Ananian2021-08-081-2/+1
| | | | | | | | | | | | | This is a bug fix release of RemexHtml, required by the latest version of Parsoid. RemexHtml migrated to a new namespace in 2.3.2. Since we don't support aliases in our phan configuration in core, update all uses to the new namespace to satisfy phan. Depends-On: I30f01f4a2a5479bb82c9b952ffa68a478215828a Depends-On: Iedf446635ee2112cfe637d8ebcf8092f0976bd17 Change-Id: I74fc929e4a66b28bfb1800ff0cd751c86e4a9f50
* Allow core to use remex-html 2.3.2C. Scott Ananian2021-08-081-1/+2
| | | | | | | | | | | | | | | | This is a bug fix release of RemexHtml, required by the latest version of Parsoid. RemexHtml migrated to a new namespace in 2.3.2 and uses aliases for compatibility. Once we upgrade mediawiki-vendor we can rename all the uses in core and turn off aliases again. Due to T287419, we need to suppress some phan issues because phan ends up running against both remex 2.3.1 *and* 2.3.2 in different CI jobs. These suppressions are removed in the follow up I74fc929e4a66b28bfb1800ff0cd751c86e4a9f50. Change-Id: I42edd4fb8cd277ea20e331994fcbe56b52bf3f06