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
Revert a58948d64 and instead remove wfShellWikiCmd and escape
shell arguments directly.
This should be fine since mwdoc-filter.php does not depend on per-wiki
state.
Change-Id: Id9c6ca84bab827675b71ca16bf688fd3f5c993a1
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.
Also update some defect links.
Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
The behaviour stays the same (extract type from @var comment and
insert into source code between e.g. "protected" and "$name") but
implemented using PHP's tokenizer instead of global regexes.
This fixes the problem with slashes being found inside the
documentation comment and various other edge cases, such as use
of slashes inside comments.
Also fix the problem with PHP namespaces being misinterpreted
as a Doxygen /command by escaping slashes automatically. This
shouldn't conflict with actual commands, since we use '@' for
all commands (e.g. @param, @return, @since etc.)
Change-Id: Ic03a8fc9d4b4851f66c2e975d9955ba20ab92f0e
Using ResourceLoader.php as example:
$ php maintenance/mwdoc-filter.php includes/resourceloader/ResourceLoader.php
== Before ==
Filtered code:
/** Associative mapping ... */ protected array $moduleInfos = array();
/** $config */ private Config $config;
Note descriptions containing a leading slash which was matched after the type
hint in the original code.
== After ==
Filtered code:
/** Associative mapping ... */ protected array $moduleInfos = array();
/** $config */ private Config $config;
Change-Id: Idcdd487ad0f4fbabdd5665abfbb8492f5bac655a
Currently lots of member descriptions in generated Doxygen pages
have a trailing star or even just a star as their description.
This is due to the regex we use to *change* the code before Doxygen
is given the code. This filter script translates the code to be
invalid PHP that looks more like Java's strongly typed class members.
The regex has been broken up into pieces for better readabilty
but not changed in any way.
The replacement is where the fix was made. Here we now replace
with "${2}/" instead of "${2} */".
Using ResourceLoader.php as example:
$ php maintenance/mwdoc-filter.php includes/resourceloader/ResourceLoader.php
== Before ==
Filtered code:
/** @var array Module name/ResourceLoaderModule object pairs */
protected $modules = array();
/** Associative mapping ... * */ protected array $moduleInfos = array();
/** $config * */ private Config $config;
/**
* Associative array mapping framework ids
* like array( 'ext.foo.tests', .. )
* */ protected array $testModuleNames = array();
/** @var array E.g. array( 'http://.../load.php' ) */
protected $sources = array();
/** * */ protected bool $hasErrors = false;
Rendering currently at
https://doc.wikimedia.org/mediawiki-core/master/php/html/classResourceLoader.html
bool $hasErrors = false
*
array $moduleInfos = array()
Associative mapping ... *.
$modules = array()
$sources = array()
array $testModuleNames = array()
Associative array mapping framework ids like array( 'ext.foo.tests', .
Config $config
$config *
Note the stray stars in hasErrors, moduleInfos and $config. $testModuleNames
doesn't have it because it has a multi-line block comment and presumably
Doxygen tolerates spaces in the final star sequence if it's on its own line.
== After ==
Filtered code:
/** @var array Module name/ResourceLoaderModule object pairs */
protected $modules = array();
/** Associative mapping ... */ protected array $moduleInfos = array();
/** $config */ private Config $config;
/**
* Associative array mapping framework ids
* like array( 'qunit' => array( 'ext.foo.tests', .. ), .. )
*/ protected array $testModuleNames = array();
/** @var array E.g. array( 'http://.../load.php' ) */
protected $sources = array();
/** */ protected bool $hasErrors = false;
Change-Id: Id7c307dc2911ef4f1a6c2ca566c6b48735b763d7
The file maintenance/mwdoc-filter.php can be abused under certain server
configurations to read the contents of arbitrary files.
In case you
- you have deleted the maintenance folder or
- you have that folder denied in the server configuration or
- the server is processing .htaccess overrides or
- you are using PHP 5.4.0 (or later) or
- you have register_globals disabled
it is believed that you are not vulnerable.
See https://bugzilla.wikimedia.org/45355 for details.
Change-Id: I3c49439b25896a6100ce415629353bccfc84490a
We are using '@var' to document our variables and class properties,
which is unfortunately not working since '@var' is really meant to
document a function or method.
The way to fix it is to use an input filter that will rewrite our PHP
source code to pretends variables are typed. Aka something like:
/**
* A title object
* @var Title
*/
var $title;
Will be made:
/**
* A title object
* @var Title
*/
Title $title;
That is incorrect PHP code but it is properly recognized by Doxygen.
This patch as a side effect, all variables and properties will end up
being documented in addition of type hinting.
Use a hack authored by Goran Rakic at:
http://stackoverflow.com/a/8472180/276152
Change-Id: I4ead1bd1feace44496b45ed8c55f5e52c59e7694