Commit graph

275 commits

Author SHA1 Message Date
Umherirrender
c7cd5399e7 build: Use inline ignore for MediaWiki.Usage.DeprecatedGlobalVariables
This avoids addition of new code with the deprecated global,
or at least it gives extra attention on review when new code also uses
the inline ignore

Change-Id: I5c1bc5a1685c28f153d4fbe3525959930f54b557
2024-09-26 18:15:32 +00:00
Umherirrender
f09beca7ca build: Remove exclude of MediaWiki.Commenting.PropertyDocumentation
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Enable the sniff to avoids that new code is missing type declarations.

Depends-On: I4b182fda29e9cb9719c26fd01a609de2453be56d
Depends-On: I1106dd167dc2188ed91d1884e979b5cea303f722
Depends-On: I2606072015d71b4bdda70a7c149d9f55ac205a3c
Depends-On: I90ecf85cb6f639af4be1947ccfbfb16d5b84cab3
Depends-On: Ib0402017e602ad3e79b7ffbb5b02bcedae1fab6b
Depends-On: I29bc609c5148668e533a9ed9f72b29f780f00dba
Depends-On: Ib6081f5519d2294bb14f81bf399f9c45315f2b69
Depends-On: Ifbc2ce0c68865c5d32689e56c6215a5099f7478b
Depends-On: I72c7dab67ef12d229fb232311e404467260d742d
Depends-On: Id994553eaeac181775ac782423ff53928ad45466
Depends-On: Id08ee260e320d8c97c2c3576d998af1b70952f27
Depends-On: I65636f2b97b44387c4320ebfb4be6c81d6f771b9
Depends-On: I897106d15c9e43f75eb006c35a14ac49edeb3ecd
Depends-On: I39ce744ee4f4a9356b0788b6e38ece9635a5ca49
Depends-On: I8a45487483c54b50576c8cbef3f8ea7b3b19969a
Depends-On: Id7ccd48e3bf626095e2d3929831b5d87ed0be948
Depends-On: I07ce1f37d1bfb18d6e73dd008a712b3ca60a80e9
Depends-On: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
Depends-On: I217b9c906972c1f335e8e7d2b340e86a4d92c5a1
Depends-On: Ia1302c9c0528691436a0411ca62b651471811c98
Depends-On: I45c62ed8b6c2893b66f12dc60580c0267b475945
Depends-On: Ia8bbdc4dee59dfb487582dd514486ec8542951be
Depends-On: I9e5330601ded043ad24a99932fe3fa0ea6c427aa
Depends-On: I67bb532efff05b7fb01abec540620239cb4031b2
Depends-On: Ia205d578b9620960d967e2cbeb418e7e5af94dd4
Depends-On: Idf17719c875466810313f0fbbf16bc67f3e40059
Depends-On: I8b33b5f4d91c1935228e7010327dbc6ce138fc00
Depends-On: I3afaba387663320187c49ff1cdb2ff3ae01681ad
Depends-On: I48014b6464f3e7e2b7f083e67f517af0b1a9367e
Depends-On: I6ff2b1e91f28340f8f467a1d5e50cc132e142b95
Depends-On: I113b040321d27c84fe9b807c162736909e96fb20
Depends-On: I7dec01892a987a87b1b79374a1c28f97d055e8fa
Depends-On: I921c5cbe5b811c5ade9d9fad56ad3499ef8373e0
Depends-On: I46f46f1855ca32c89a276b06f4e2051ff541886e
Depends-On: I41ad89cc3112a2911ad40c55583bff2d7787da68
Depends-On: I1f306a3925d6768209a06e70082598b2f70cd319
Depends-On: Ifc27750207edc09e94af030d882b6f1a5369cf98
Depends-On: I81544e367543846654b4d03fcad5adad71e23751
Depends-On: I56a1d27ba2dfbcdd929a0e0c96664bc2a31e38f2
Depends-On: I6dd402a5bca0c2136595faedae315959bbcf17d9
Depends-On: I82b4f543ed004fc960b6b1f8ac718db2a63a40fe
Depends-On: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
Depends-On: I6087dcdac761916359009548beb5210671a32ee5
Depends-On: I73c413727a63d14efb5028b27128784c98724110
Depends-On: Ifddb6a95d0d81fef4c480ef96dbc1fc9cbb93401
Change-Id: I97a8b6fbe17a24ddffcc6a3fd4ea4451b59ba790
2024-09-18 17:27:01 +00:00
Umherirrender
be39a18332 build: Use inline ignore for Generic.CodeAnalysis.AssignmentInCondition
Avoid that new code contains this pattern.

Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446
Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9
Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0
Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8
Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e
Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
2024-09-01 00:15:10 +02:00
Dreamy Jazz
7adcc63bfe Remove populateImageSha1.php
Why:
* The populateImageSha1.php maintenance script has been in core
  since at least MW 1.19, being definitely added to update.php
  in 1.19 through 7cb4d69d9d.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateImageSha1.php

Bug: T373310
Change-Id: Ibc6a31b1eafb7c5727d68bfb2526ffd7532408a6
2024-08-26 10:27:01 +01:00
Umherirrender
3b38ab4fa7 build: Remove no longer needed sniff exclusion
The SpaceBeforeClassBrace and ExtendClassUsage sniffs
are fixed with codesniffer 44.0.0

Change-Id: I9689943fb232dc71b7a53e727da143d31cb71c02
2024-08-21 21:41:28 +02:00
Taavi Väänänen
ed7e787f32
Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyle
Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.

Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
2024-04-22 18:26:14 +03:00
jenkins-bot
17e5741710 Merge "build: Remove phpcs PSR2.Classes.PropertyDeclaration.Multiple exclusion" 2024-04-22 15:24:19 +00:00
Taavi Väänänen
6151a420d7
Fix MediaWiki.Commenting.PropertyDocumentation.SpacingAfter issues
Fixes some MediaWiki.Commenting.PropertyDocumentation.SpacingAfter PHPCS
errors by converting doc-comments into regular comments.

Change-Id: Iac8fece839e0a54855bb1f431d2ee88a5783ddab
2024-04-22 14:17:03 +03:00
Taavi Väänänen
9cb7cd443c
Use ignore comments for MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage
Instead of globally ignoring this sniff, convert the current violations
(which set the variable so can't be fixed easily yet) to use local phpcs
comments to silence the errors.

Change-Id: I490cbf4915e2705383edb4a2fc5ddc1efd55c960
2024-04-22 14:17:02 +03:00
Taavi Väänänen
51efb24870
build: Remove phpcs PSR2.Classes.PropertyDeclaration.Multiple exclusion
Change-Id: I7999d20e6ba7bd3a5669ea5ae13aba7c1548c1e0
2024-04-22 12:52:37 +03:00
Umherirrender
f3524224f0 build: Fix line indents
Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of
arrays for parameters is wrong

Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
2024-03-11 00:14:16 +01:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
DannyS712
a14047b8d6 phpcs: drop exclusions of preprocessorFuzzTest.php script
Script was removed

Follow-up: Ib845f1bc2cd5c452a998b01612d45fe59e8ffc37
Change-Id: Ifd96c0eed5872630aeaba8efb0663e46943bcd0e
2023-09-22 03:25:05 +00:00
Lucas Werkmeister
49ba7597a1 phpcs: Exclude some docs/ subdirectories
Based on .eslintignore; docs/html/, in particular, can contain a handful
of PHP files that shouldn’t be linted. (All four directories are
generated, see .gitignore and docs/html/.gitignore.)

Change-Id: I0fb06d4a6c716680850de93096395650afe3802b
2023-07-21 10:57:23 +02:00
Umherirrender
3bbd8e7984 tests: Resolve maintenance phpunit filename deprecation errors
PHPUnit wants the filenames of the tests to match the class name being
tested.

Bug: T337333
Change-Id: I3d568521121f8cd5e15e87a7ee2ba4800139fa41
2023-07-09 22:34:35 +02:00
Nikolas Nyby
e87316c4a4 Resolve GlobalFunctions phpunit filename deprecation errors
PHPUnit wants the filenames of the tests to match the class name being
tested.

Bug: T337333
Change-Id: Icc450c900b6d4589515d86889403043a5e4ef690
2023-07-01 09:30:42 +00:00
Umherirrender
a01256c5b8 build: Cleanup of .phpcs.xml
Use inline suppression for known exception from eval/passthru/query call

Change-Id: Ie85ea5698a615adf07e4e391bf06d102149effd5
2023-04-13 12:57:51 +02:00
Fomafix
3dce04e1a5 Rename PHP classes to match filenames
Also change the letter case in the file names to be consistent to other
files in includes/specials.

The PHPCS exclude-pattern for these files on
MediaWiki.Files.ClassMatchesFilename.NotMatch can now removed.

The old class names are still available as aliases and are deprecated
now.

Change-Id: Id71f5a5ce456caf522c95c477487e14f366c1b40
2023-03-16 12:55:20 -04:00
libraryupgrader
7375f3a5fe build: Updating mediawiki/mediawiki-codesniffer to 41.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Usage.ForbiddenFunctions.eval

Change-Id: I6fd0a9296c88a77c3abec6e5e8d568bb469c2d6e
2023-03-11 19:04:09 +00:00
Kevin Israel
7c07484ade maintenance: Migrate mcc.php from CommandLineInc to Maintenance
This allows methods to be defined instead of global functions, which in
this case, were missing the "wf" prefix.

Change-Id: I2413675f46a29d914cb756071cd6abbcf38b500e
2023-01-14 02:02:59 +00:00
Kevin Israel
f9fb7d6988 tests: Use MW_VERSION instead of deprecated $wgVersion
Change-Id: Ie4d1c7e660535fff9d0513b7ca4e6479f12bd51b
2023-01-05 05:20:00 -05:00
Kevin Israel
31d8dcbc30 phpcs: Remove exclusions for files that were deleted or moved
* maintenance/benchmarks: 4 files were deleted in d814a74b6f.
  1 file was deleted in 4c5de97a9b.
* includes/Stub*.php: 3 files were moved in 0fff5089ba to a
  new subdirectory. phpcs:ignore comments were added in the move.

Change-Id: I8b2c71e0e054f969741691f29dca62adeab757bd
2022-12-20 05:37:47 -05:00
Kevin Israel
dc31aaad74 phpcs: Remove 3 items from PrefixedGlobalFunctions ignore list
Since 096ea23208, these no longer exist as global functions:

* moveToExternal
* resolveStub
* resolveStubs

Change-Id: I1c36ece4d84895647a27aaf7160ac3b66c402f01
2022-12-20 00:23:09 -05:00
Kevin Israel
a70e8fa299 phpcs: Remove comment regarding silence (at-sign) operator in tests
This comment was added in 355a6cd4c3 and quickly became outdated.
While it should still mostly be correct, it is no longer "policy" to use
the at-ease library. The "@" operator is now explicitly permitted where
necessary and is now recommended even outside tests (T253461). As such,
it no longer makes sense to keep this comment around.

Change-Id: I07aa84d46be8c7e5a1c8a3249d382cbbfef80267
2022-12-03 05:05:40 -05:00
Kevin Israel
1937e2a7d6 tests: Fix missing "wf" prefix for global functions
Also:

* In .phpcs.xml, remove "showUsage" from the list; transstat.php was
  removed in e19f4e16a6.
* In styleTest.css.php, check the type of the $_GET value as part of the
  "basic sanitization".

Change-Id: Icb82d8a42dd6cd062f41a04696f092b43b04f54f
2022-11-28 07:28:55 -05:00
Umherirrender
c6fecd5ab0 tests: Replace assertEmpty with assertSame
assertSame avoids use of loose comparisons and
allows to check the expected type

Change-Id: If821d1be2bc1ff9f8b70968a339f33c7a8e8880a
2022-11-25 00:42:53 +01:00
Fomafix
7a9f03b20a Remove PHPCS exclude-pattern for */languages/*
Since 863a1d5bdd the converter classes are in own files.
therefor the exclude for the rule
Generic.Files.OneObjectStructurePerFile.MultipleFound is not needed
anymore.

Change-Id: Id10ba77fc4caf9065a8f0e3480f42aad492275e4
2022-10-19 06:09:17 +00:00
Fomafix
330c0c0b41 Remove PHPCS exclude-pattern */languages/*
The Language converter classes are not in this folder anymore and don't
use the pattern of two classes in one file anymore.

Change-Id: Ie25bc2fe4ad860c218145615caefbfee2200d1c6
2022-10-15 12:34:37 +00:00
libraryupgrader
b70581e4ca
build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 38.0.0 → 39.0.0
  The following sniffs are failing and were disabled:
  * MediaWiki.PHPUnit.AssertEmpty.AssertEmptyUsed

* php-parallel-lint/php-console-highlighter: 0.5 → 1.0.0
* php-parallel-lint/php-parallel-lint: 1.3.1 → 1.3.2

npm:
* grunt-banana-checker: 0.9.0 → 0.10.0
* grunt: 1.5.2 → 1.5.3
* karma: 6.3.15 → 6.4.1
* async: 2.6.3 → 2.6.4
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25
* got: 11.8.3 → 11.8.5
  * https://github.com/advisories/GHSA-pfrx-2q88-qq97

Change-Id: I1d7bc9c9599b48d2bd837617cad409a31adb362a
2022-10-07 21:09:37 +03:00
Daimona Eaytoy
1c60cafab4 Add @coversNothing to all structure tests
With PHPUnit 9, tests without @covers tags are considered risky and emit
warnings. Not having @covers is bad practice anyway, so use
@coversNothing instead to make the intention clear, and re-enable the
phpcs rule.

Also rewrite an assertion in ResourcesTest that was bothering me.

Bug: T243600
Change-Id: I6dd683f93b6b2faed5f107be2ca7860602277fbc
2022-10-07 03:21:54 +02:00
Amir Sarabadani
2b9fd5176d Drop support for doctrine/dbal < 3.0.0
Removes various hacks and back compat support

Bug: T270740
Change-Id: I17d74705cdd5a2e1af0bda66bfa466067b8387a8
2022-09-29 10:49:17 -04:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Revert of a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).

Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Timo Tijhof
f745292c69 maintenance: Move MWTerm classes to /tests/parser/
This further removes files that are not maintenance scripts from this
directory. It isn't used outside of tests, either.

While at it, rename this to a PSR-4 namespace consistent with some of
the other test-only classes.

Change-Id: Ibc49617631f17a5e9489789a90a7b8537340ead3
2022-03-24 21:01:14 +00:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Tim Starling
54c735354f Stop using is_resource() where possible
* Enforce the ban on is_resource in phpcs
* In OrderedStreamingForkController, the comment was incorrect. I
  confirmed using a small test script that if the child closes one end
  of a socket pair, the other end will still be open, and is_resource()
  will still return true, and fclose() will not fail. The issue was
  introduced in c82d30d19c, it was not present in the
  CirrusSearch copy of the class.
* Allow is_resource() for debug logging.
* Allow is_resource() for parameter validation where a stream may be
  passed to a function, since there is no alternative.

Bug: T260735
Change-Id: I59a752f7bb4b043ddfb2434b52a02f9221bf54db
2022-01-26 10:03:23 +11:00
Alexander Vorwerk
e73e07e85b Use inject Config in api modules and special pages
Replacing the usage of global vars with the usage of the injected
Config instance.

Change-Id: I90612b4dde9b76afb1bac4855274c03dcaf23044
2021-12-01 13:01:02 +00:00
Tim Starling
65b1b6b56a Remove $wgShellLocale, always use C
$wgShellLocale was a flawed solution to the problem of locale
dependence. MediaWiki has its own concept of locale (the Language
hierarchy) and any kind of dependence on the server's libc locale is
incorrect and harmful, leading to bugs. Developers have an expectation
that functions like strtolower() will work in a certain way, and
respecting the locale set in the environment at install time violates
this expectation.

The problems with using C as a locale, which led to $wgShellLocale, are:

* escapeshellarg() will strip non-ASCII characters. This can be worked
  around by not using it. The security vulnerability it was trying to
  fix can be prevented in another way.
* Shell commands like rsvg will fail to correctly interpret UTF-8
  arguments. This is the reason for the putenv(). On Linux, this can
  be fixed by using C.UTF-8, which we didn't know at the time. On
  Windows, the problem is not relevant (there are unrelated issues
  with UTF-8 arguments).

Bug: T291234
Change-Id: Ib5ac0e7bc720dcc094303a358ee1c7bbdcfc6447
2021-09-24 17:25:01 -07:00
Alexander Vorwerk
1a22c1c1d7 Remove global function mimeTypeMatch()
This is done without a deprecation process since the function is
@internal and completely unused outside of core.

Bug: T291341
Change-Id: I4b074f83f9be67b5b5bc2d33b2a6a55bb109a2b3
2021-09-19 19:03:46 +00:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
With this patch deprecation warnings will be emitted
if $wgUser is accessed or written into. The only pattern
of usage still allowed is

$oldUser = $wgUser;
$wgUser = $newUser;
// Do something
$wgUser = $oldUser;

Once there is no deprecation warnings, we know that nothing
legitimately depends on $wgUser being set, so we can safely
remove the code that's still allowed as well.

Bug: T267861
Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
2021-09-15 20:17:04 -07:00
Fomafix
12f9cba673 Rename PHP class RandomPage to SpecialRandomPage
This change is for consistency to the file name and to other classes.

The old class name RandomPage is kept as alias for compatibility and is
now deprecated.

Also change the letter case in the class names and file names:
* SpecialRandompage     -> SpecialRandomPage
* SpecialRandomredirect -> SpecialRandomRedirect
* SpecialRandomrootpage -> SpecialRandomRootPage

The change of the letter case of file names may cause problems on
Windows operating systems.

Change-Id: If4dd23126e0d032f42a86aff7d09414edcb1ade2
2021-09-03 09:26:06 -07:00
DannyS712
57139640c5 phpcs: remove class name exclusion for invalidateUserSessions
Follow-up: I0c0f5c94a7ee0aa3f0aeb8b7f84857022810f17a
Change-Id: I0e24cf641ad16330ee152e80dbcad6a2f71a7001
2021-08-24 11:40:09 +00:00
libraryupgrader
5357695270 build: Updating dependencies
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
2021-07-22 03:36:05 +00:00
Umherirrender
7f684ed81c build: Cleanup and improve .phpcs.xml
Use /* at the end of exclude-pattern when excluding the whole folder,
see Id95236edbd3d87f57719d235c7c9cee366180099 for explaination

Remove the file extension when excluding the whole folder,
because it process php files only by the extensions argument set to php

Change-Id: Icaad23ab4b1708a5ce17930f77067ac9224169b5
2021-04-29 20:51:09 +00:00
James D. Forrester
623f80ff04 Follow-up dcdec1a2b: Also update path to file in .phpcs.xml exclusions
Change-Id: I21597266131aca1d0190f4eee4a42fc8335da74b
2021-04-29 13:00:15 -07:00
Reedy
2b40657a36 .phpcs.xml: Replace useage of whitelist in comments
Bug: T277987
Change-Id: I7735279b4dceceb0c9620bb0983ca4839245f194
2021-04-18 16:22:58 +01:00
DannyS712
7aba39a718 Update .phpcs.xml to remove deleted maintenance scripts
Scripts that were removed:
* maintenance/archives/upgradeLogging.php
* maintenance/benchmarks/bench_wfIsWindows.php
* maintenance/minify.php

Change-Id: I05c198e7f1bf8e8f57ba82cce4223fe73c6af3f9
2021-04-14 00:38:20 +00:00
libraryupgrader
649d0cb4f2 build: Updating eslint-config-wikimedia to 0.19.0
Additional changes:
* Dropped .php5 and .inc files from .phpcs.xml (T200956).

Change-Id: I66c9980d3ef6f6604c3145ad0b7f308257dff046
2021-03-12 10:55:29 +00:00
James D. Forrester
bdddfb92ba Drop wgContLang, deprecated in 1.32
Bug: T245940
Depends-On: Ib7fe7318100c0aadc3aa759416bf787913a9b788
Change-Id: I75c3b6715abd5eaf3619337cab8b1844e9a8349a
2021-03-08 13:27:28 -06:00