aboutsummaryrefslogtreecommitdiffstats
path: root/includes/PathRouter.php
Commit message (Collapse)AuthorAgeFilesLines
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Improve documentation about object to be stdClass or specific typeUmherirrender2020-11-201-3/+3
| | | | | | Some classes still needs exclude for the sniff Change-Id: I9536c2ee84f6fb4c83cf862a152cf6b00344cb97
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-3/+3
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Setup: Move wgArticlePath validation to its main consumer (PathRouter)Timo Tijhof2019-09-251-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | The variable is also read in a few other places, such as to export the value from api.php (siteinfo) and load.php (mw.config) but those requests don't need to be held back by this extra logic. Alternatively, if we really want to require this for all consumption, we should probably let PathRouter provide the value and require consumers to use it. E.g. services->getPathRouter->getArticlePath, or something like that. As easy first step, I'm moving it to PathRouter, called from WebRequest::getPathInfo which is still called on all index.php requests for any wiki page action in any namespace (incl Special) when the wiki uses anything other than the default 'index.php?title=' article path. Test Plan: * Set '$wgArticlePath = 'bla';` * View /mediawiki/index.php/Main_Page, and observe the fatal error message (same as before this change). Bug: T189966 Change-Id: Id06c2557e2addb58faeef0b6f7767a65b8de55a5
* Setup: Move wgActionPath logic to PathRouterTimo Tijhof2019-09-041-0/+18
| | | | | | | | | | | | | | | This is only relevant when processing page views or when constructing Title urls with an 'action' query. Pretty important stuff, and worth optimising for if we had to choose, but we can defer it in this case without slowing it down, which is better for everything else. It also means we don't mutate configuration (beyond setting whole values as dynamic defaults), which seems desirable, and makes the overall behaviour easier to test. Handling absence of 'view' should be PathRouter's responsibility, not Setup. Bug: T189966 Change-Id: I9c1eea2dcea74be0e283eb2b175268315ced1793
* Use [...] instead of array(...) in PHP comments and documentationFomafix2019-06-171-6/+6
| | | | Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
* Collapse some nested if statementsReedy2019-04-041-4/+2
| | | | Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
* Avoid a few overly complicated is_null() checksThiemo Kreuz2019-03-111-1/+1
| | | | | | | | | We can use the ?? syntax introduced with PHP 7.0 because it is already supported by HHVM, even when HHVM is set to be compatible with PHP 5.6. This was inspired by Ib117e05. Change-Id: If980839fe6f86f2b4e86bbe99905a796e4708c7c
* Avoid a redirect loop when the request URL is not normalizedTim Starling2018-07-161-6/+23
| | | | | | | | | | | | | | | | | | | | | | If the request URL was not normalized, for example having a double slash in it, this could cause it to fail to match in the PathRouter. But the canonicalizing redirect was using the normalized URL, causing a redirect loop exception. So: * If the PathRouter fails to match with the original URL, try matching against the normalized URL. This allows it to still work for normalized URLs with a double slash in the title part of the path. * Have WebRequest::getFullRequestURL() always return the URL without removing dot segments or interpreting double slashes. Just append the path to the server. * Make MediaWikiTest.php use WebRequest instead of FauxRequest, allowing it to reproduce the exception in question. Add relevant test. * Add tests for the new PathRouter behaviour. Bug: T100782 Change-Id: Ic0f3a0060904abc364f75dae920480b81175d52f
* Use a closure instead of PathRouterPatternReplacerTim Starling2018-07-111-45/+35
| | | | | | | | | | | | | | | In PHP 5.3+ it's simpler to use closures rather than a replacer class to pass parameters through to the preg_replace_callback() callback. Remove without deprecation internal class PathRouterPatternReplacer, unused in core and Gerrit-hosted extensions. The new implementation is very similar, except that I renamed some variables for clarity. Also fixed an incorrect doc comment parameter type. Change-Id: I4cd3c0162acdb02d51ab5b7f03b0a16e0a818d99
* Cleanup some incorrect return annotationsErik Bernhardson2016-12-121-1/+1
| | | | | | | | | | | | | | Most of these are simply changing annotations to reflect reality. If a function can return false to indicate failure the @return should indicate it. Some are fixing preg_match calls, preg match returns 1, 0 or false, but the functions all claim to return booleans. This is far from all the incorrect return types in mediawiki, there are around 250 detected by phan, but have to start somewhere. Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
* Clean up array() syntax from docs, part VIAmir Sarabadani2016-09-121-8/+8
| | | | Change-Id: Ib0eea494e2065c7ab356dc45fd174544a9c1c942
* Convert all array() syntax to []Kunal Mehta2016-02-171-14/+14
| | | | | | | | | | 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
* Fixed some @params documentation (includes/*)umherirrender2014-04-221-13/+13
| | | | | | | | | Swapped some "$var type" to "type $var" or added missing types before the $var. Changed some other types to match the more common spelling. Makes beginning of some text in captial. Also added some missing @param. Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
* PathRouter: Fix documentation typoTimo Tijhof2014-03-071-1/+1
| | | | Change-Id: Ib8021c721e7438163d65ddf6b83ecee8fc1639c6
* Fixed spacing in files direct in includes folderumherirrender2013-04-211-5/+5
| | | | | | | Added spaces before if, foreach Added some braces for one line statements Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
* Fixed @param tags to conform with Doxygen format.Tyler Anthony Romeo2013-03-111-4/+4
| | | | | | | | | | | Doxygen expects parameter types to come before the parameter name in @param tags. Used a quick regex to switch everything around where possible. This only fixes cases where a primitve variable (or a primitive followed by other types) is the variable type. Other cases will need to be fixed manually. Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
* fix some spacingumherirrender2013-02-041-1/+1
| | | | Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
* Added missing GPLv2 headers in some places.Alexandre Emsenhuber2012-05-111-0/+21
| | | | | | Also made file/class documentation more consistent. Change-Id: Ia45d0756cd84138da267bf1cbd1a58be7f28c6d1
* Parameter documentation for PathRouterReedy2012-04-251-2/+29
| | | | | | Explicitly define member variable Change-Id: Iae2cffbb299d587d9a48b3b3255a0b49501cabac
* Fix documentation to match potential codeReedy2012-04-071-2/+2
| | | | Change-Id: Ibaaa2e82777178d8b25a19c4bec7aaed0239a277
* Fix bug 34684 in my PathRouter code:Daniel Friesen2012-02-241-12/+44
| | | | | | | | | - Update the tests to test extra characters and patterns like like \\ and $1 - Also update the tests to make sure that matches that don't have enough data to work fail - Replace the str_replace and preg_match based code with code based on preg_replace_callback. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/112313
* Fixing some of the "@return true" or "@return false", need to be "@return ↵Sam Reed2012-02-091-4/+4
| | | | | | | | | bool" and then the metadata can say true if foo, false if bar Other documentation improvements Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/111052
* Followup r104676, r104688:Daniel Friesen2011-12-091-1/+47
| | | | | | | | | | - Update our woefully out of date doc comment for WebRequest::getPathInfo (we haven't simply been extracting a PATH_INFO for ages) - Make PathRouter::makeWeight protected - Add more comments to the PathRouter code - Add two more edge case tests to the PathRouter tests. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/105629
* FU r104688:Aaron Schulz2011-12-081-13/+14
| | | | | | | | | * Removed a bit of cruft in from a comment (c&p error) * Clarified 'value' params comment (AFAIK) * Broke some long lines and made some other w/s cleanups Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/105510
* Followup r104274, r104676. Fix the bug that broke fr. Forgot to rawurldecode ↵Daniel Friesen2011-11-301-15/+15
| | | | | | | | | | path contents. Also add /u just for sanity sake. Add new tests for url encoding, unicode, and length edge cases. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104688
* Recommit PathRouter code from r104274, r104284, r104285 without the ↵Daniel Friesen2011-11-301-0/+272
| | | | | | | WebRequest.php and hooks.txt code so we can start to add tests and fix the bug in it. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104676
* Revert r104274, r104284, r104285 -- breaks special pages on non-englishBrion Vibber2011-11-281-272/+0
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104474
* Followup r104274; Add '$key' to the $data array as well.Daniel Friesen2011-11-261-0/+3
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104285
* Implement path routing code.Daniel Friesen2011-11-261-0/+269
- Makes extending paths with extensions simpler. - Should fix bug 32621 by parsing paths based on pattern weight rather than pattern order. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104274