Commit graph

12 commits

Author SHA1 Message Date
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
Matthew Flaschen
b510edbda1 Revert "Convert mwdoc-filter.php to Maintenance", rm wfShellWikiCmd
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
2017-05-04 00:15:22 +00:00
Matthew Flaschen
a58948d645 Convert mwdoc-filter.php to Maintenance class so --wiki works
Change-Id: Ie2fc4109bc2e7a23a6549d9705be44cf2eb858b9
2017-05-03 03:35:36 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Timo Tijhof
222ef664fc Doxygen: Rewrite mwdoc-filter to fix bug with slashes in comments
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
2015-11-23 23:02:13 +00:00
Timo Tijhof
8c34c8ed5e doxygen: Document problem with slashes and fix a few
Change-Id: I39f8f394e7421fca71e7d26818f7118e85de7e4f
2014-09-23 19:32:13 +00:00
Timo Tijhof
01a7b4343a doxygen: Fix leading space in class member descriptions
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
2014-09-23 03:07:18 +00:00
Timo Tijhof
3fba44335a doxygen: Fix trailing star in class member descriptions
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
2014-09-23 03:07:12 +00:00
umherirrender
bfb75bc8e2 Fixed spacing around parenthesis in languages/tests/maintenance
Change-Id: Idd4299d17f1fcf98ab1d635484cb4e880f35ee24
2013-04-28 15:57:34 +00:00
Platonides
892329cfba (Bug 45355) Read of arbitrary files through mwdoc-filter.php
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
2013-02-25 16:07:43 +01:00
Alexandre Emsenhuber
73ae67c6ed Improve documentation of maintenance scripts.
Change-Id: I557f85e8526a3e4b48107fbf299ff39f6af1ac12
2012-08-05 12:00:37 +02:00
Antoine Musso
ab59fadb39 (bug 38492) let doxygen document variables
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
2012-08-01 20:44:40 +02:00