Commit graph

51 commits

Author SHA1 Message Date
Umherirrender
465777f188 Use const keyword for constant list of strings or ints
Also changed visiblity of some to private

Change-Id: I113b040321d27c84fe9b807c162736909e96fb20
2024-09-11 23:16:24 +02:00
Dreamy Jazz
e7393b3cc7 Exclude boilerplate maintenance code from code coverage reports
Why:
* Maintenance scripts in core have bolierplate code that is
  added before and after the class to allow directly running
  the maintenance script.
* Running the maintenance script directly has been deprecated
  since 1.40, so this boilerplate code is only to support a now
  deprecated method of running maintenance scripts.
* This code cannot also be marked as covered, due to PHPUnit
  not recognising code coverage for files.
* Therefore, it is best to ignore this boilerplate code in code
  coverage reports as it cannot be marked as covered and also
  is for deprecated code.

What:
* Wrap the boilerplate code (requiring Maintenance.php and then
  later defining the maintenance script class and running if the
  maintenance script was called directly) with @codeCoverageIgnore
  comments.
* Some files use a different boilerplate code, however, these
  should also be marked as ignored for coverage for the same
  reason that coverage is not properly reported for files.

Bug: T371167
Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
2024-08-27 13:22:29 +01:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
Ebrahim Byagowi
a717db8e60 Add namespace and deprecation alias to FormatJson
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
2024-05-16 16:28:01 +03:30
Taavi Väänänen
9553121e2a
maintenance: Fix PSR2.Classes.PropertyDeclaration.Multiple errors
Change-Id: I9eb336837b21aa37327f571aad4f973592bdddf7
2024-04-21 23:06:00 +03:00
Reedy
72df6cb8da libs/composer: Namespace under Wikimedia\Composer
Change-Id: I5ffedacf31e60fb0f38e308f8dcf010e577f919e
2024-01-13 20:10:25 +00:00
Matěj Suchánek
676fcf4379 Replace substr with cleaner string methods
Use str_starts_with, str_ends_with or string offset where appropriate.

This fixes a bug in MimeAnalyzer where the "UTF-16LE" header could not
be identified because of wrong constant. This is the exact type of bug
that the new functions can avoid.

Change-Id: I9f30881e7e895f011db29cf5dcbe43bc4f341062
2023-05-20 15:40:21 +02:00
C. Scott Ananian
4cb3957cf0 Remove $wgParserTestFiles, deprecated in MW 1.30
This global variable was replaced by auto-discovery of parser test
files in extensions and is no longer needed (or used).

Change-Id: Ib616e60f36db32ffd8bc69c71a096f23c0a27910
2022-10-13 09:22:22 -04:00
Reedy
22f743fb0a Attempt to automatically fix start of config vars being __DIR__
Change-Id: I69514d7a691f8d60280198fa48fbc794cbe6c4c0
2019-11-04 16:21:04 +00:00
Daimona Eaytoy
b5cbb5ab3f Upgrade phan config to 0.7.1
This allows us to remove many suppressions for phan false positives.

Bug: T231636
Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
2019-09-04 08:20:53 +00:00
Daimona Eaytoy
327e8ea416 Unsuppress phan issues part 6
Bug: T231636
Depends-On: I50377746f01749b058c39fd8229f9d566224cc43
Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
2019-09-01 09:48:45 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Daimona Eaytoy
7f7efbe026 Globally unsuppress phan issues with low count
All of these suppression prevent the detection of many common mistakes,
and could easily prevent things like T231488. Especially if there are
few issues of a given type, it's way better to suppress them inline,
instead of disabling them for the whole core.
This patch only touches the one with a lower count (although those
counts may be out of date).

Bug: T231636
Change-Id: Ica50297ec7c71a81ba2204f9763499da925067bd
2019-08-30 09:40:47 +00:00
Thiemo Kreuz
cc329a5b06 Update PHPDoc types in several maintenance scripts and related
There is like a billion of these in our core codebase. I would love to
update them all. But I don't have the time, at least not to do them all
at once.

TL;DR: It's an improvement. :-)

Change-Id: I0a9c51bdcf0f261f971586bb8703f418324b0f98
2019-03-07 17:54:26 +00:00
Umherirrender
a81cf72d63 Filter autodiscovered parser tests in ConvertExtensionToRegistration
Since MediaWiki 1.30 files under tests/parser/ automatically included
into the parser test run when using extension registry.
When migrate an extension to extension.json do not include the file when
it is autodiscovered.

Bug: T170037
Change-Id: I57f49610a47f0e62a1512e3769c6dbb0d845d6fb
2018-04-13 20:44:59 +02:00
Umherirrender
0483765086 convertExtensionToRegistration: Set requires key in extension.json
The highest manifest version is not supported from the start of
extension.json
For extensions converted to this highest version the mininum core
version must be specified to avoid load problems in the extension.

Using 1.29.0 for manifest version 2 due to T149757 /
Id1071fc0647892438e5cd0e3ee621fbdaaa64014

Change-Id: Iea5ba589c70958db7500cf3587b5ebd738532026
2018-02-05 06:56:24 +00:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.

Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
2017-11-21 21:34:16 -07:00
Kunal Mehta
12113ce79f registration: Fix adding $formerGlobals in conversion script
Using + for two arrays does not work if they are using numerical
indexes.

Bug: T142344
Change-Id: I49541bd344fa81d20c9b4cf61b968b58137ab140
2016-08-08 02:56:39 -07:00
Kunal Mehta
2b39f1ea2d registration: Add hint about UnitTestsList hook in conversion script
Change-Id: Ia161c2e10943e75c98ee8e0d2341bc2c9a418faf
2016-08-07 02:27:09 -07:00
Kunal Mehta
85b84f73b3 registration: Update conversion script for manifest_version 2
Config settings are now an object, with the value set as the 'value'
key.

Change-Id: Iba3999fdfc8994d50331825c9a416334db602e46
2016-07-24 11:46:53 +00:00
Brad Jorsch
35ea435cb8 registration: Add --config-prefix to convertExtensionToRegistration.php
For converting extensions that use custom prefixes.

Change-Id: I4fcf7ff2af04e9a0367de368503f2c70d8fed959
2016-05-26 17:58:19 +00:00
Gergő Tisza
c68ae9d561 registration: Ignore short variables in convertExtensionToRegistration
substr returns false when the string is shorter than the initial
position, which makes array_key_exists freak out.

Change-Id: I38c2dd3a1ae5d700d66ff590dda4be67e4dc5514
2016-05-20 18:56:40 +00:00
Florian
5d2df74a46 registration: Fix mode of files (755 -> 644)
Follows up 7c4d73183c.

Change-Id: I779534561ccb38b4c0f2ca5771dcb0aa810f930a
2016-05-06 18:26:07 +00:00
Florian
7c4d73183c registration: Allow string value for Hooks
Instead of forcing an object even for single-hook-listeners, allow
string values, too (one hook listener for one hook, only). Also:
use it as default for the conversion script, if only one listener
is added to a hook (which is usually the case). This leads into a
much cleaner output of the Hooks section of extension.json.

Bug: T133628
Change-Id: Ie9e54f0931c41706eb8d82d00256698992ec41cc
2016-05-03 13:23:07 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
victorbarbu
3a7d5067c7 convertExtensionToRegistration.php: die on global functions
Bug: T122952
Change-Id: I0fca5457aba3a7237ad7aeb96f3f6636d73863d3
2016-01-09 21:50:11 +00:00
Florian
9dec78d4c0 convertExtensionToRegistration: Detect if composer autoloader is needed
If an extension specifies a require section in its composer.json, which contains
some dependencies, we can assume that this extension needs to load the composer
autoloader.

The maintenance script convertExtensionToRegistration.php will now check if the
extension has such a composer.json and, if so, adds the load_composer_autoloader
property in extension.json, which will try to load the autoloader of composer
is it is present.

Also add a check for existence of a require section in ComposerJson library
(ComposerJson::getRequiredDependencies()). 

Bug: T119766
Change-Id: Icdbc37abc44e642afee2aab4c0e9298d3471124d
2016-01-07 17:23:34 +00:00
Paladox
318546d6b8 registration: When converting, place 'namemsg' under 'name'
Currently when converting from PHP to extension.json, 'namemsg' isn't
underneath 'name', it is halfway down instead.

Change-Id: I1be42a818bda6908643702cc5f7c959d2d2fdfba
2015-12-14 16:55:38 +00:00
Mark A. Hershberger
89282735ff Add error checking for file argument
If the user ignorantly passes in ".", this will fail.

Change-Id: I1128945b7277ce7b3da27eb30b2dfbbf644c9d38
2015-11-12 17:15:07 -05:00
umherirrender
c81540d725 Remove deprecated $wgSpecialPageGroups
$wgSpecialPageGroups is deprecated since 1.21
override SpecialPage::getGroupName instead

Remove also SpecialPageFactory::setGroup because it no long can set $wgSpecialPageGroups.
Also remove SpecialPageFactory::getGroup along with its setter.

All replaces in extensions can be found under:
https://gerrit.wikimedia.org/r/#/q/status:open+branch:master+topic:wgSpecialPageGroups,n,z
https://gerrit.wikimedia.org/r/#/q/status:merged+branch:master+topic:wgSpecialPageGroups,n,z

Change-Id: I1aa8f98bf326b2e54d7403efbb9f002a106cefc5
2015-06-26 19:19:17 -07:00
paladox
889f83dc9b Fix phpcs warnings
Change-Id: I2d7dbf7314257a3ad8f5f6b97a6949a2500d298f
2015-06-17 20:06:42 +00:00
Vivek Ghaisas
5132a68683 Remove multiple empty lines in functions
Functions must not contain multiple empty lines in a row
(Squiz.WhiteSpace.SuperfluousWhitespace sniff).

Bug: T102774
Change-Id: Ib706e4fc34b95c0d7c887e54af0ea61227767d8f
2015-06-17 13:30:57 +03:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Kunal Mehta
a1368a3d9b registration: Version the extension.json schema
Versioning the extension.json schema will allow us to make breaking changes
to the schema in a non-breaking manner.

Extensiosn and skins will set a 'manifest_version' value, stating which
version of the schema the file is written for. Processor::extractInfo() will
be  passed the version number, and can switch behavior depending upon it.

For backwards-compatability, a version number of 1 is assumed if none is set.
The validateRegistrationFile.php script will emit a warning if this is the
case.

Bug: T99344
Change-Id: I2086a1465ceaeedd1ccc6804fda2c304ad16ffa0
2015-05-28 22:20:59 +00:00
jenkins-bot
5bb693f6d4 Merge "registration: Don't ignore empty array config settings when converting" 2015-05-21 17:33:05 +00:00
Kunal Mehta
e66864878a registration: Don't ignore empty array config settings when converting
Remember which settings we set to an empty array and then only skip
those settings.
The weird variable name "$__settings" is used to avoid any conflicts
similar to what eval.php does.

Bug: T98739
Change-Id: Iefbf8a98fd433cfbe0087aca6821d90c2786b0cb
2015-05-21 10:22:05 -07:00
umherirrender
d06aaa9b20 Do not allow setting deprecated $wgSpecialPageGroups over extension.json
$wgSpecialPageGroups is deprecated since 1.21
The code should be migrated to override SpecialPage::getGroupName before
adding an extension.json to the extension, instead of allowing setting
this over extension.json

Also added a warning to convertExtensionToRegistration.php for the no
longer supported global

Change-Id: Idccbe41b649de93548c5b0fca03145da716bcc65
2015-05-16 22:26:33 +02:00
Kunal Mehta
2b81c4ca36 registration: Add support for $wgParserTestFiles
Bug: T97921
Change-Id: I9a736a4c0ff739c4acf742b8f17792544851b28e
2015-05-02 23:16:54 -07:00
Kevin Israel
c9b73a38bc convertExtensionToRegistration.php: Ignore i18n shims
Bug: T91350
Change-Id: I18b35db14a13f58909bce83fec11bf9e8f10672d
2015-04-30 23:32:44 -04:00
jenkins-bot
0cd36fec25 Merge "convertExtensionToRegistration: Still convert $wgTrackingCategories" 2015-04-07 16:18:19 +00:00
Kunal Mehta
77a813f21f registration: Support ResourceModuleSkinStyles
Structurally, it's set up exactly the same as ResourceModules, so we can
re-use the same code.

Bug: T91566
Change-Id: I7cd1330edc3e97b4658c81aac67071a90ac61fb6
2015-04-07 08:43:16 -07:00
Kunal Mehta
912a5e5ec3 registration: Add resource template-like functionality to extension.json
This allows for extensions to specify common arguments to ResourceLoader
module definitions by only specifying them once.

The only supported values are "localBasePath" (which is relative to the
current directory), "remoteSkinPath", and "remoteExtPath". If a module
is using a custom class or is already specifying paths, the default paths
will not be added.

Tests are included to cover existing functionality and newly added
functionality. The convertExtensionToRegistration.php script was also
extended to try and guess what the default paths should be.

Bug: T88786
Change-Id: I802461796e8d8584dacf3b0c811b5ba97a4a8f7f
2015-02-09 15:14:06 -08:00
Kunal Mehta
024ad10b45 convertExtensionToRegistration: Still convert $wgTrackingCategories
It's an attribute now rather than a global, but we still want
to convert it.

This follows up 247ecab445.

Change-Id: Ibb61b1689e3e6b454d7bf2f300ab465e30ca774a
2015-01-29 15:21:14 -08:00
Kunal Mehta
89c3ef0baf convertExtensionToRegistration: Add --skin option
To write to skin.json instead of extension.json

Change-Id: I0e7dfbd871b7f80958fe7033d4595a205bb34293
2015-01-29 12:24:49 -08:00
Kunal Mehta
76972de9ca convertExtensionToRegistration: Document parameters
Bug: T87620
Change-Id: I0326632c24bf429cd09f4e51f6e6990536d6c76f
2015-01-26 15:02:03 -08:00
Kunal Mehta
f777e4500d convertExtensionToRegistration: Move 'namemsg' to top as well
Change-Id: Ib2bac10980fee3bb2704219a80ec55a4b8c55607
2015-01-26 21:24:19 +00:00
Kunal Mehta
77d38f651f convertExtensionToRegistration: Put some keys (name, version, etc.) on top
Bug: T86608
Change-Id: I4b8e48e8d2d23c3b7e3f0b49bfa9c8941b5a3434
2015-01-13 11:31:45 -08:00
Kunal Mehta
f6cc92c74b Handle more cases in convertExtensionToRegistration.php
* Handle constructs like $wgResourceModules += array(...)
* Support $wgMessagesDirs['FooBar'] = array(...)
* Handle stripping paths where it is the current directory
* Use FormatJson::ALL_OK when writing the file

Bug: T86311
Change-Id: I9434f6634fd6e460a5c2f6dac95c9065da35a51a
2015-01-13 02:05:33 +00:00