wiki.techinc.nl/tests/phpunit/structure
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
..
ApiPrefixUniquenessTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
ApiStructureTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
AutoLoaderStructureTest.php Safer autoloading with respect to file-scope code 2021-01-11 11:59:36 +11:00
AvailableRightsTest.php Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
ContentHandlerSanityTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
DatabaseIntegrationTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
ExtensionJsonValidationTest.php Fix visibility of setUp/tearDown 2020-06-16 21:02:05 +02:00
PasswordPolicyStructureTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
ResourcesTest.php [ResourcesTest] Replace ReflectionObject with TestingAccessWrapper 2020-10-30 13:34:58 +00:00
RestStructureTest.php Handle CORS preflight request and prevent anon users from unsafe methods 2020-09-21 19:29:40 -04:00
SpecialPageFatalTest.php Use generator in SpecialPageFatalTest 2020-11-21 19:45:28 +01:00
StructureTest.php MediaWikiTestCase to MediaWikiIntegrationTestCase 2020-06-30 17:02:22 +01:00
SuiteDirectoryTest.php phpunit: Add structure test for suite.xml registering all test suites 2020-04-02 01:47:48 +00:00