aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/GlobalFunctions
Commit message (Collapse)AuthorAgeFilesLines
* Hard deprecate wfUrlProtocolsWithoutProtRel and wfMatchesDomainList, ↵Ebrahim Byagowi2025-03-241-0/+2
| | | | | | | | | | deprecated since 1.39 They have been deprecated since 1.39 in favor of UrlUtils::validAbsoluteProtocols and UrlUtils::matchesDomainList. Bug: T319340 Change-Id: Iff5fa7a3e517be15e4d60d96ab97f3f0575a1825
* Deprecate wfArrayDiff2()Bartosz Dziewoński2024-10-191-0/+1
| | | | | | No longer used anywhere. Change-Id: I7c35e92e2926489f140b86bca13efaf4144f4057
* Hard deprecation of wfExpandIRIEbrahim Byagowi2024-09-071-13/+0
| | | | | | | Deprecated since 1.39, now let's emit warning. Depends-On: Ib08a0cc47a7b0d8ec7375d4505b447c4b770d4ef Change-Id: I6bd166b998b2283ef0fb2de56a517b74d004f991
* Use MediaWikiIntegrationTestCase::getConfVar in testsFomafix2024-08-061-1/+1
| | | | Change-Id: I3a99f24da3d572281b49a8a8b92e006fde3eaa41
* Use constants provided by MainConfigNames for config namesFunc2024-05-181-1/+1
| | | | Change-Id: I2f29ea8227da64b79b70fcce3decb6e34ea8da5b
* Autofix spacing around commasDaimona Eaytoy2023-10-251-1/+1
| | | | | | | | | | | This was done automatically using the `Universal.WhiteSpace.CommaSpacing` sniff, which will be included in the next release of the MW PHPCS config. Some of these have been adjusted manually where the autofix broke vertical alignment. Change-Id: I54a4668d8a2759b9d7de47742c943a535a04e211
* Follow RFC 3986 on what is path in mailto URLsPetr Pchelko2023-09-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This hack was originally added to wfParseUrl as a fix for T10324 specifically for LinkFilter, however according to the RFC 3986 this is wrong. RFC defines that in URLs the authority component must start with //, so in urls without //, e.g. news: or mailto: there is no authority component, and thus no host component, everything after : is actually a path, so default PHP parse_url is correct. RFC even has an example: > For example, the URI <mailto:fred@example.com> has a path of "fred@example.com". It's fairly ugly to just copy-paste the hack into LinkFilter, but I didn't find an easy and elegant way to rewrite it without making any changes to the link indexes values stored in the DB. See https://datatracker.ietf.org/doc/html/rfc3986 Co-Authored-by: 沈澄心 <dringsim@qq.com> Change-Id: I3dd04495db9c7a66f62c3914c0eff06754b7d560
* Resolve GlobalFunctions phpunit filename deprecation errorsNikolas Nyby2023-07-013-0/+0
| | | | | | | | PHPUnit wants the filenames of the tests to match the class name being tested. Bug: T337333 Change-Id: Icc450c900b6d4589515d86889403043a5e4ef690
* Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-1/+1
| | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-1/+1
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-281-0/+1
| | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* 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
* Remove hard-deprecated wfReadOnly/wfReadOnlyReasonUmherirrender2022-09-231-44/+0
| | | | | Bug: T283978 Change-Id: I2ef829bb9f5b89d4b9c77718ca2e090b0cbd3264
* tests: Migrate `setMwGlobals()` to `overrideConfigValue(s)`Derick Alangi2022-07-274-19/+21
| | | | Change-Id: I13a82dc57a86f74c713a11eff26488bee06903e2
* Hard deprecate wfReadOnly/wfReadOnlyReasonUmherirrender2022-06-281-0/+3
| | | | | Bug: T283978 Change-Id: I99177bedc32e219dc2e6ae6e114787d0602bfb22
* Fix silently skipped UrlUtilsTestTim Starling2022-05-163-34/+16
| | | | | | | | | | | | phpunit --filter UrlUtilsTest would execute no tests because the class was already loaded by the GlobalFunctions data providers via the autoloader, so PHPUnit sees no additional classes when it examines UrlUtilsTest.php. So, split out all providers in UrlUtilsTest to a separate class which can be safely autoloaded. Change-Id: I483736ee70e598cdb19f8203bc6885f1c234fc42
* Refactor URL-parsing global functions to classAryeh Gregor2022-04-123-316/+20
| | | | | | | | | | | | | | The new class, UrlUtils, is usable standalone or as a service. Using it as a service will just automatically load a few settings from site configuration. In addition to just making our code cleaner, this will enable making some of Setup.php's dynamic configuration more sane. Test coverage is all lines except invalid URLs -- I couldn't find any. Bug: T305093 Change-Id: I706ef8a50aafb518e13222719575d274c3583b90
* Remove deprecated global function wfWikiID()Alexander Vorwerk2022-03-291-24/+0
| | | | | | | deprecated since 1.35 and unused Bug: T298059 Change-Id: I0c601b67beaf8218b7fd7ca46a8caeb1452f4d76
* Tests: expected value goes first in PHPUnit assertionsDannyS7122022-03-041-1/+1
| | | | Change-Id: I74b6d0175c2d83e403f339bdb9a557b806813ab6
* tests: Change use of AtEase to at operatorTimo Tijhof2022-02-241-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359. Per T253461, not mass-changing source code, but the use of the native error silencing operator (@) is especially useful in tests because: 1. It requires any/all statements to be explicitly marked. The suppressWarnings/restoreWarnings sections encourage developers to be "lazy" and thus encapsulate more than needed if there are multiple ones near each other, which would ignore potentially important warnings in a test case, which is generally exactly the time when it is really useful to get warnings etc. 2. It avoids leaking state, for example in LBFactoryTest the assertFalse call would throw a PHPUnit assertion error (not meant to be caught by the local catch), and thus won't reach AtEase::restoreWarnings. This then causes later code to end up in a mismatching state and creates a confusing error_reporting state. See .phpcs.xml, where the at operator is allowed for all test code. Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
* tests: Replace some usages of Wikimedia\(suppress|restore)Warnings()Reedy2022-02-241-2/+3
| | | | Change-Id: I361fde0de7f4406bce6ed075ed397effa5be3359
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-2/+1
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Hard deprecate the global function wfWikiID()Alexander Vorwerk2022-01-101-1/+5
| | | | | | | deprecated since 1.35 and unused Bug: T298059 Change-Id: I14ba3e7c98215cd584d7f99df2b5b4a198e6eab8
* wfParseUrl: add regression test for T294559daniel2021-10-291-0/+28
| | | | | | | | As of PHP 7.2, parse_url does not correctly handle ports on protocol relative URLs. Ensure that we properly compensate for this. Bug: T294559 Change-Id: I52c661cbff5e6f28120b50111659255d712d6887
* Merge "Revert "wfParseUrl: rely on parse_url for proto-relative urls""jenkins-bot2021-10-281-8/+0
|\
| * Revert "wfParseUrl: rely on parse_url for proto-relative urls"Urbanecm2021-10-281-8/+0
| | | | | | | | | | | | | | | | | | This reverts commit 66e58d1ea783e7b02ef64fce1acce03297cbdfd0. Reason for revert: let's revert and hope this will fix T294559 Bug: T294559 Change-Id: I2e4ae268e288f87b6c80fac08d275118f5b5cbd7
* | Fix PHP warning with some inputs to wfCgiToArray()Bartosz Dziewoński2021-10-211-1/+4
|/ | | | | | | Also add some more tests for it. Bug: T294017 Change-Id: I8a4faa42c2219ce415fbb82a248b07a28b59157d
* wfParseUrl: rely on parse_url for proto-relative urlsPetr Pchelko2021-10-181-0/+8
| | | | | | | | | | | | | | | | | | On July 12 2011 in df2306b97 Roan added this workaround for parse_url lacking support for protocol-relative URLs. In 2012 PHP 5.4.7 came out, that added support for protocol-relative URLs to parse_url, see [1]. It's 2021, and after a decade of honorably serving our community, this workaround can be now be retired. It's not a simple deletion since we have custom 'delimiter' bit that wfParseUrl returns, and we need to keep supporting that. [1] https://bugs.php.net/bug.php?id=62844 Change-Id: If9b3bb2a51afa7af1ba8e674eadaa8db4f6f33f9
* GlobalFunctions: Test clean up for wfExpandUrl()Timo Tijhof2021-09-251-91/+56
| | | | | | Prep for a larger change to keep review small and simple. Change-Id: I31f1403ab40c79ab270c4170d2afd6e885a2caac
* Remove global function mimeTypeMatch()Alexander Vorwerk2021-09-191-25/+0
| | | | | | | | This is done without a deprecation process since the function is @internal and completely unused outside of core. Bug: T291341 Change-Id: I4b074f83f9be67b5b5bc2d33b2a6a55bb109a2b3
* Cleanup mixed space/tab line indentUmherirrender2021-09-041-2/+3
| | | | Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
* build: Updating dependencieslibraryupgrader2021-07-223-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
* Drop global function wfNegotiateType, deprecated in 1.36James D. Forrester2021-05-101-46/+0
| | | | | | | No uses known in code search. Bug: T264984 Change-Id: Ia69d3a11653671d46e71f9248e0e62445f4f9d54
* Drop global function wfDebugMem, deprecated in 1.36James D. Forrester2021-05-101-17/+0
| | | | | | | No uses known in code search. Bug: T264976 Change-Id: I9f7553ea405cc096a1d6596e1d6511e7dd634009
* MediaHandlerFactory: inject a loggerDannyS7122021-03-311-1/+5
| | | | | | | Instead of using wfDebug Also normalize the entries Change-Id: Ie539233c8b95eaae370732f97681989821157299
* WfExpandUrlTest use yield for test casesDannyS7122021-03-011-11/+8
| | | | | | | Instead of needing to store them all in $retval Change-Id: I1d42375931cfb0b7afbbb15c79ec3fca07caf047
* Remove hard deprecated wfIsBadImage()Taavi Väänänen2020-12-291-48/+0
| | | | | Bug: T249459 Change-Id: I363ec383295aff8a2d6cc89b1f0df5369a537473
* Deprecate a bunch of global functionsDannyS7122020-12-181-0/+4
| | | | | | | | | | | | | | | | | * wfAcceptToPrefs * wfClearOutputBuffers * wfConfiguredReadOnlyReason * wfDebugMem * wfGetPrecompiledData * wfNegotiateType Bug: T264976 Bug: T264979 Bug: T264981 Bug: T264983 Bug: T264984 Bug: T264985 Change-Id: Ia05bc84e4d1be7c8a02472f32e2c009e4bb32032
* Don't access $wgRequest from UserTim Starling2020-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | Some User methods fail if they are called before $wgRequest is set. But according to the Setup.php comment, it is only set for b/c. The global request object can be lazy-initialised at any time. This is sufficient to avoid T263911 (loss/obfuscation of the $wgServer error message). In tests, try to keep $wgRequest and RequestContext::$request in sync. Introduce MediaWikiIntegrationTestCase::setRequest() which sets both at once, and use that instead of setMwGlobals() or direct assignment. BlockManagerTest was accidentally exploiting the fact that the global context request and $wgRequest were separate objects. Making them the same causes session cookies to appear in the response, breaking the cookie counts. Use a new response for the test. Bug: T263911 Bug: T245940 Change-Id: I2be99f7251a837bc6b62be0b152038157dec10f2
* Remove deprecated wfMemcKey() functionAaron Schulz2020-11-231-11/+0
| | | | | Bug: T266502 Change-Id: I1e4b20cc30fa3ef4671d8b80e660b2ac3f469d80
* Remove deprecated wfForeignMemcKey()Aaron Schulz2020-10-261-13/+0
| | | | | Bug: T250407 Change-Id: Ie9352d297382689a2fc2634e1160d7fe7b91e89b
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-306-6/+6
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* Hard deprecate wfIsBadImage()Reedy2020-06-091-0/+1
| | | | | | Bug: T249459 Depends-On: Iec58118198864704b1860aeb630476391e3a2c23 Change-Id: I939ded72427adc973739e7b376ea85cbf4b3e258
* wfIsBadImage: Remove deprecated $blacklist parameterReedy2020-06-091-12/+1
| | | | | | | wfIsBadImage still used in Flow\Parsoid\Fixer\BadImageRemover Bug: T254646 Change-Id: Ieb1ba83593da5c7789b9da5b6a931eedcd391bf3
* build: Bump mediawiki-codesniffer to 31.0.0Daimona Eaytoy2020-05-301-0/+1
| | | | | | | | | Done with `composer fix` and suppressing the rest (i.e. sniffs for global variables, which for core should be suppressed anyway). Additionally, add `-p` to `phpcbf`, as otherwise it just seems stuck. Change-Id: Ide8d6cdd083655891b6d654e78440fbda81ab2bc
* GlobalFunctions: Fix wfPercent() with negative accuracyMax Semenik2020-05-041-0/+1
| | | | | | | | | | | | | | | Format strings like "%.-1f" have never been valid, however while previously it would have resulted in output being "1f", in PHP 8 it's an exception. The existing unit test failed because (float)"1f" evaluates to 1, which was rounded down to an expected 0. Adding another test case to make sure it can return anything other than "0%" on PHP 7. While I'm at it, fix wrong phpdoc and add parameter types to this function. Bug: T248925 Change-Id: I018bc17a563c58535f6c84644d707251ab19cd0a
* tests: Refactor GlobalTest to use a data providerMax Semenik2020-05-011-13/+11
| | | | Change-Id: Iba800edd9ca35650f79b933db48eb8f95bd09f04
* Use MediaWikiServices::getMessageCacheUmherirrender2020-03-141-1/+3
| | | | Change-Id: I07fcc9529991adc634c10e5ed8498ac138a1c2b7
* debug: Remove $wgDebugTimestamps featureTimo Tijhof2020-02-241-2/+0
| | | | | | | | | | | | | | | | | | | | | MediaWiki provides at least a dozen distinct ways that debug logs can be generated, augmented and displayed, and even more ways for profiling information can be collected. This makes it difficult to reason about overall and isn't helping with on-boarding. Reduce investments to only a few methods and make them great, starting by removing possibly the least useful profiler we have today (relative to the others we've developed since then), which is the "relative timestamps and memory use" prepended to wfDebug messages, which would presumably be used in conjuction with $wgDebugComments, $wgDebugToolbar or $wgDebugLogFile of which the latter two already includes timestamps and/or offsets. If this is truly useful, I suggest we (unconditionally) make use of offsets in (one of) those instead. Originally introduced in r61582 (b1e2b87b9578). Change-Id: I09d1cb0d3f5b0b3165ed4d299b71c051b78a1918