Commit graph

10 commits

Author SHA1 Message Date
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
Umherirrender
6ea3d6ac2c Add explicit casts between scalar types
php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts

Found by phan strict checks

Change-Id: I92daeb0f7be8a0566fd9258f66ed3aced9a7b792
2022-03-08 16:59:01 +00:00
Reedy
354848b0cd maintenance: Mark some closures as static
Bug: T274036
Change-Id: Ic959dfddcf2867e4cf26970f375b347f4b41584d
2021-02-07 02:18:30 +00:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
Many files were in the autoloader despite having potentially harmful
file-scope code.

* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce  "NO_AUTOLOAD" tag which excludes the file containing it
  from the autoloader. Use it on CommandLineInc.php and a few
  suspicious-looking files without classes in case they are refactored
  to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
  they do not contain dangerous file-scope code. It's slow (15s) but
  its results were enlightening.
* Several maintenance scripts define constants in the file scope,
  intending to modify the behaviour of MediaWiki. Either move the
  define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
  doMaintenance.php, per the original convention which is supposed to
  allow one maintenance script to use the class of another maintenance
  script. Using require breaks autoloading of these maintenance class
  files.
* When Maintenance.php is included, check if MediaWiki has already
  started, and if so, return early. Revert the fix for T250003 which
  is incompatible with this safety measure. Hopefully it was superseded
  by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
  things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
  more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
  Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
  left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
  caller.

Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
2021-01-11 11:59:36 +11:00
Reedy
9ee7179d15 Remove some checks for extension_loaded( 'intl' )
ext-intl is required by MW now, so composer will enforce requirement

Bug: T267669
Change-Id: I6fcc19e06b95e58def4364a24b8de100dd6f3f90
2020-11-29 00:06:32 +00:00
Umherirrender
bd7ff019c9 Check for intl extension in updateCredits.php
Change-Id: Ifa2892b2f38fa73362c3ac60e1d90614cdbc0a93
2019-02-01 19:57:56 +01:00
Bartosz Dziewoński
25d8d26071 updateCredits: Fix collation name
'uca-default-u-kn' is a valid name for MediaWiki's category collation
functionality ($wgCategoryCollation / Collation class), not for PHP's
collation functionality (Collator class).

'uca-default-u-kn' for Collation maps to 'root-u-kn' for Collator
(see Collation::factory()), and the '-u-kn' suffix is later stripped
to enable numeric collation (see IcuCollation::_construct()).

This doesn't seem to result in any changes in the output.

Change-Id: I8cc7d283aee5408f8b7bed365661ff286236a694
2017-07-28 17:24:03 +00:00
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
Bartosz Dziewoński
acb085d21a updateCredits: Do not change working directory
This allows the script to be used by MediaWiki extensions.
Example in UploadWizard: I181dda3ca3ef3f43e863482057b4949c1bc32e9b.

Change-Id: Ib121c6e226bdc1b3a8976c96b8d9f21546a1b5d3
2016-11-21 16:03:08 +01:00
Bryan Davis
08d54bc01c Convert CREDITS to list of all known git contributors
* Add an updateCredits.php script that will merge the existing
  contributors list with a list generated using git-log.
* Update the existing .mailmap file to de-duplicate author list
* Update CREDITS using updateCredits.php

Bug: T139300
Change-Id: If00ae955c8026d6be38575f3766a06c46e5e7126
2016-10-20 09:42:18 +00:00