Commit graph

10 commits

Author SHA1 Message Date
Brad Jorsch
ca3789a271 AutoloadGenerator: Filter PSR4-compliant classes instead of ignoring directories
Per discussion in T166010, we're going to handle class aliases (e.g. for
BC) by including the class_alias() call in the same file as the target
class. When the target class is a PSR4-compliant class, we still need to
pick up that alias for inclusion in autoload.php.

Thus, instead of excluding whole directories, we need to process the
files and filter out only those found classes that are PSR4 compliant.

Bug: T204983
Change-Id: I1c516998df368531c90ea54acc5be8be96e1db6c
2018-09-20 15:15:27 -04:00
Kunal Mehta
251a0b97e5 Treat phpdbg as run from the command line when checking PHP_SAPI
phpdbg is a gdb-style debugger for PHP that is run from the command
line. However, it has a different PHP_SAPI value, so it was impossible
to run maintenance scripts with it (until now).

To avoid having to check both PHP_SAPI values in a bunch of places,
introduce wfIsCLI() to easily check whether running from the
command-line or not.

We're (CI team) interested in generating code coverage with phpdbg
instead of xdebug, hence this patch.

Bug: T184043
Change-Id: Id1f994ca146d7858cd8bb6ab6cdbb7718ff524fb
2018-01-03 23:00:37 -08:00
Kunal Mehta
036f5b47ef Enable using PSR-4 autoloader for MediaWiki core and extensions
This adds support for a PSR-4 (<http://www.php-fig.org/psr/psr-4/>)
autoloader, so instead of needing to manually list each class, just the
namespace prefix is needed.

Extensions can set a "AutoloadNamespaces" property in extension.json to
register PSR-4 compatible namespaces to be autoloaded.

The implementation is based off of the example implementation
(<http://www.php-fig.org/psr/psr-4/examples/>) with some modifications
for performance, notably cutting down on function calls, and only trying
to look up classes that are namespaced.

The generateLocalAutoload.php script will ignore any directory that is
registered as a PSR-4 namespace.

Bug: T99865
Bug: T173799
Change-Id: Id095dde37cbb40aa424fb628bd3c94e684ca2f65
2017-12-12 00:20:11 +00:00
Florian
23c79b228c Structure test: Add autoload.php order check
If a class is added manually to the autoload.php another run of
the maintenance script will probably add unnecessary noise to
another change. The added structure test checks, if the output of
the maintenance script equals to the contents of the commited
autoload.php.

Bug: T121921
Change-Id: I3a426b92892f4c00cab33a13f6a717751120367c
2016-08-03 09:50:27 +00:00
Max Semenik
1b2e2cd975 Fix generateLocalAutload.php
Installer overrides rework in I2661ba2036b2887d31ab356751d731cc8b499f26
made this exception uneeded, remove.

Change-Id: I952a1237ebe3d2ac86182488f1c0e297c7c6e304
2016-06-09 12:57:25 -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
umherirrender
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00:00
Erik Bernhardson
5711d81126 Doc: Mention the php command in autoload.php to regenerate it
Adds a comment to the top of the generated autoload.php directing
developers to the command to regenerate the file so they may just
copy and paste the command.

Change-Id: If098a1eb51ed732378677215c0e438c73d506697
2014-11-17 16:35:32 +00:00
Kevin Israel
0a68289a8f generateLocalAutoload.php: Abort for web requests
The Maintenance class already does this, though this script does not use it
for the obvious reason that when there is a missing or incorrect autoloader
entry, it may not be possible to initialize MediaWiki.

Hence it is necessary to do that explicitly in this script. Overwriting
autoload.php potentially could disrupt the operation of a production wiki
(the file is truncated when it is opened).

Change-Id: I05d5d4b7c30c4643e71ca5819783627688e15da7
2014-11-14 18:16:24 -05:00
Erik Bernhardson
396a76f2ff Generate $wgAutoloadLocalClasses with a maint script
Currently all new classes in core need to be registered
with the autoloader.  This is acceptable but inconvenient.

This patch adds a script to read the output of php's tokenizer
to determine the names of all the classes within mediawiki core.
Patches with new or removed classes will just need to rerun
the maint script rather than manually adjusting the arrays.

A full conversion to psr-0 + composer would solve this as well,
but this is a very non-intrusive patch that can get us some
portion of the benefit(reduced manual maintenance) today rather
than months down the line once we figure out all the intricacies
of mediawiki + composer.

Change-Id: I8b1bdb84a9699de79f8b9951fa61e5437d083c55
2014-11-13 15:41:31 -08:00