aboutsummaryrefslogtreecommitdiffstats
path: root/includes/parser/LinkHolderArray.php
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge "parser: Inline private callback in LinkHolderArray::replaceText"jenkins-bot2019-11-221-28/+14
|\
| * parser: Inline private callback in LinkHolderArray::replaceTextThiemo Kreuz2019-09-261-28/+14
| | | | | | | | Change-Id: I3389fc4464bfb6fd7d06130f16b9eefa5d1d0594
* | Remove Parser::serializeHalfParsedText() and helpersTim Starling2019-11-011-129/+0
| | | | | | | | | | | | | | | | | | | | It was deprecated in 1.31, It was a failed experiment, intended to improve performance, but it never worked and makes the code much more complex. I also removed two LinkHolderArray helpers which were accidentally not marked deprecated -- codesearch confirms that they are not called by anything. Change-Id: I74754265dde388b590f0b4c995cb4a35a1318299
* | Fix new phan errors, part 3Daimona Eaytoy2019-10-121-2/+5
|/ | | | | | | | | | | | These are almost only doc changes, with two exceptions: 1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths 2-In ExtensionRegistration, changed a line to throw an Exception immediately, instead of an ExtensionDependencyError. This is because the latter takes an array with msg and type, but we were passing it a plain string (and in fact the code was bugged). Bug: T231636 Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
* Globally unsuppress phan issues with low countDaimona Eaytoy2019-08-301-0/+1
| | | | | | | | | | | | All of these suppression prevent the detection of many common mistakes, and could easily prevent things like T231488. Especially if there are few issues of a given type, it's way better to suppress them inline, instead of disabling them for the whole core. This patch only touches the one with a lower count (although those counts may be out of date). Bug: T231636 Change-Id: Ica50297ec7c71a81ba2204f9763499da925067bd
* Make use of the list() feature where it makes senseThiemo Kreuz2019-03-241-2/+1
| | | | | | | | | | This code is functionally identical, but less error prone (not so easy to forget or mix these numerical indexes). This patch happens to touch the Parser, which might be a bit scary. We can remove this file from this patch if you prefer. Change-Id: I8cbe3a9a6725d1c42b86e67678c1af15fbc5961a
* Various fixes for phan-taint-checkBrian Wolff2019-02-171-0/+2
| | | | | Bug: T216348 Change-Id: I0adafdc680dae0e930f38f08fe926645c57be06c
* Update LinkHolderArray to use ContentLanguageAryeh Gregor2018-08-111-6/+4
| | | | | Bug: T200246 Change-Id: Ic954f7752fda8e2a1f34a64b85cce27774014666
* Pass $title to 'GetLinkColours' hookBartosz Dziewoński2018-07-311-2/+2
| | | | | | | | | | | | I think it's reasonable for link "colours" to depend on the page on which they are shown. It seems similar to how self-links are handled. The $colours variable is not cached, so title-specific link colours will not "leak" to other titles. Used in ProofreadPage in Ic910c2c33a6f1f8a70d9a122fbd2128428f29bd5. Bug: T199288 Change-Id: I7378102a3e06544e9e695b255982c9bb0cfbf3a2
* StringUtils: Deprecate Replacer classesKevin Israel2018-07-121-5/+8
| | | | | | | | | | | | | | | | | | The Replacer classes were added in 1.9, when MediaWiki supported PHP 5.0 and 5.1. They were designed to be used with preg_replace_callback() and StringUtils::delimiterReplaceCallback(). Now that Closures exist in PHP 5.3 and newer, there is no need to define a class for this purpose. All existing Replacer subclasses are simple enough that their few uses can easily be replaced with Closures, without making the code harder to understand. In fact, the code probably becomes easier to understand, as what each match is replaced with becomes more obvious -- no need to refer to a separate class. MediaWiki code search finds no uses in extensions. Thus, these classes are hard deprecated immediately. Change-Id: I441c21689909fb06a1ea07a305259eeb82cb2345
* Avoid deprecated LinkCache::singleton()Kunal Mehta2018-06-101-2/+4
| | | | Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-1/+1
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* Add quotes to comment based strip markersPhantom422017-12-081-10/+10
| | | | | Bug: T180159 Change-Id: Ic9dbb8ef3948fe751d16c3963769b616b5db2fc7
* Add missing & to @param documentation to match functon callUmherirrender2017-08-111-4/+4
| | | | Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
* Replace use of &$thisBrad Jorsch2017-01-311-1/+1
| | | | | | | | | Use of &$this doesn't work in PHP 7.1. For callbacks to methods like array_map() it's completely unnecessary, while for hooks we still need to pass a reference and so we need to copy $this into a local variable. Bug: T153505 Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
* Remove empty lines at end of functionsumherirrender2016-11-051-4/+0
| | | | | | | | It looks like there is something missing after the last statement Also remove some other empty lines at begin of functions, ifs or loops while at these files Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
* Rename DB_SLAVE constant to DB_REPLICAAaron Schulz2016-09-051-2/+2
| | | | | | | | | This is more consistent with LoadBalancer, modern, and inclusive of master/master mysql, NDB cluster, and MariaDB galera cluster. The old constant is an alias now. Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
* Move Linker::getLinkColour() into LinkRendererKunal Mehta2016-05-271-5/+4
| | | | | | | | | | | * Rename to getLinkClasses() since it's not really returning colours, but CSS classes. * Dependency inject LinkCache into LinkRenderer * Update all callers of Linker::getLinkColour(), and mark it as deprecated (no other uses in Gerrit) * Update a bunch of tests for new dependency Change-Id: Id178e2dcc60b833ce2dbad4920896b93cabba1bf
* Parser: Replace Linker::link() with LinkRendererKunal Mehta2016-05-261-18/+17
| | | | | | | Replaces usage of Linker::link() in Parser and LinkHolderArray with the new LinkRenderer. Change-Id: Icb796ef08d70926728732ab5468940c09ba5eaf8
* Add LinkCache::getSelectFields() and use it in a few placesKunal Mehta2016-05-131-20/+10
| | | | Change-Id: Ic65b20cc2aa41f9b481e280918fe95c57da53221
* LinkHolderArray: Title::makeTitle() does not return nullKunal Mehta2016-05-121-3/+0
| | | | Change-Id: I587a34459d4bcc1bae33631561fa6d4a91dfa4a5
* LinkHolderArray: Use LinkBatch for generating WHERE in queryKunal Mehta2016-05-121-15/+6
| | | | | | | The entire query could be replaced with LinkBatch, but that will require further refactoring. Change-Id: I87cf2a391486e36e73a13baac65d243fc9196b5c
* Convert all array() syntax to []Kunal Mehta2016-02-171-42/+42
| | | | | | | | | | 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
* Fix not-loaded DbPageLanguage when Title::getPageLanguage() get's calledFlorian2016-02-161-2/+8
| | | | | | | | | | | | | | | | | If the Title object isn't the title of the current viewed WikiPage, the page_lang field of the database isn't requested. This results in the problem, that Title::getPageLanguage() always returns the default content language, even if the page language is different (changed with Special:PageLanguage, if wgPageLanguageUseDB is true). That is problematic for the Translate extension, which relies on the correct page language. This change makes sure, that getPageLanguage() always return the correct page language. If the page language isn't loaded already, Title::getPageLanguage() now does a database lookup (if $wgPageLanguageUseDB is true) to get the correct page language. It will use LinkCache for the page_lang field. Bug: T121666 Change-Id: I0ae5ea39f7a124ed427ca5dfb26c1a116b27a94e
* Use stub threshold from ParserOptions when parsingBrad Jorsch2016-02-081-1/+4
| | | | | | | | | | Linker::linkAttribs() needs the stub threshold to determine the classes in some cases. For the code path from Parser → LinkHolderArray → Linker, we can pass down the correct threshold from ParserOptions instead of pulling a potentially-different threshold from $wgUser. Bug: T124367 Change-Id: I16b9d6c3044ae60d5a7fd340569c019ffc4b2a55
* phpcs: Assignment expression not allowedumherirrender2015-11-181-8/+11
| | | | | | | | | Fix some "Assignment expression not allowed" Found by tests: https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull Change-Id: Ibfc62b0aaa5c7fa63081edea3ef2b4d0dc984f85
* Fix issues identified by SpaceBeforeSingleLineComment sniffVivek Ghaisas2015-09-261-2/+2
| | | | Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
* Remove unneeded empty lines at begin of if/else/foreach bodyumherirrender2015-06-191-1/+0
| | | | | | An if body must not begin with an empty line Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
* Fix phpcs errors in includes/Ricordisamoa2015-01-081-1/+0
| | | | | | Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
* Removed remaining profile callsAaron Schulz2015-01-081-6/+0
| | | | Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
* Remove obvious function-level profilingChad Horohoe2015-01-071-10/+0
| | | | | | | | | | | Xhprof generates this data now. Custom profiling of various sub-function units are kept. Calls to profiler represented about 3% of page execution time on Special:BlankPage (1.5% in/out); after this change it's down to about 0.98% of page execution time. Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
* Replace wfRunHooks calls with direct Hooks::run callsAaron Schulz2014-12-101-2/+2
| | | | | | * This avoids the overhead of an extra function call Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
* Remove documentation hinting LinkHolderArray::replace() should return valueReedy2014-11-101-4/+2
| | | | | | | | Return value not used in any code in our repo Removes FIXME too Change-Id: Ia2ec35099f0b54ea39c2f6b9371e94c3034bddb0
* Title::getContentModel(): load from DB if necessaryKevin Israel2014-08-201-6/+18
| | | | | | | | | | | | | | Also don't cast $model to int in LinkCache::addGoodLinkObj(); content model IDs are non-numeric strings, not integers, so that field was always populated with the value 0. Because 0 is a falsy value, this caused subsequent calls to Title::getContentModel() to return the default model rather than the correct one. Also (hopefully) fixed every single query that could cause a LinkCache entry to be added without the content model. Bug: 69789 Change-Id: I94f06baf406afa538cd2b10139598442f9fc6759
* Fix phpcs issues in parseraddshore2014-08-121-16/+17
| | | | | | | | This fixes all issues except for: - class names - line length Change-Id: Ie91b010d5b3eec49d3b80b6e93b125a901ef43c6
* Cleanup some docs (includes/[m-r])umherirrender2014-07-241-1/+1
| | | | | | | | | | - Swap "$variable type" to "type $variable" - Added missing types - Fixed spacing inside docs - Makes beginning of @param/@return/@var/@throws in capital - Changed some types to match the more common spelling Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
* Merge "De-duplicate pages in replaceInternal"jenkins-bot2014-07-021-1/+1
|\
| * De-duplicate pages in replaceInternalReedy2014-07-011-1/+1
| | | | | | | | Change-Id: If534308040201f0c4f9d315fae508c7dd3f53ee9
* | Function type hints for LinkHolderArray.phpReedy2014-07-011-0/+13
|/ | | | Change-Id: I5e429baab774a790b3558732f9c87637adfbe4ce
* Revert "Declare visibility on class properties of includes/parser/"Ori.livneh2014-05-161-13/+3
| | | | | | | | | See https://bugzilla.wikimedia.org/65375#c4 This reverts commit f359cdf61462782743a87943938ef4cce78b2647. Bug: 65375 Change-Id: I12a60b5cc52a07a6deabcbf47c7c99cd2faac3c3
* Various documentation updates for includes/parser/Siebrand Mazeland2014-05-111-1/+4
| | | | Change-Id: I16dd3a792cc83f8c80b3652d42c055730f6d177a
* Fix most CodeSniffer issues in includes/parser/Siebrand Mazeland2014-05-111-2/+4
| | | | | | | Remaining are the classes containing underscores and possibly a few other issues that will be addressed soonish. Change-Id: Icf56374c71afc134420ebbcfecf12dcb29dc9564
* Declare visibility on class properties of includes/parser/Siebrand Mazeland2014-05-111-3/+13
| | | | Change-Id: If03a9bd5eb83be4d15f54e73f49f42540fb7d5fc
* Fixed some @params documentation (includes/parser)umherirrender2014-04-221-12/+15
| | | | | | | | | 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: I49f8f48b521878de7abd9cc40efdeff6cf9a37e0
* Add Title::hasFragment and use itumherirrender2014-01-241-1/+1
| | | | | | Makes checks against the fragment easier to read and all the same. At the moment some using strval, some use type safe comparsion. Change-Id: I27d9c3e40e6de6800f4488de167cf06e83c88ce6
* Revert "Include short descriptions for extensions bundled in the release"MaxSem2014-01-121-70/+68
| | | | | | | | Contains var_dump(), self-merged non-trivial code. This reverts commit 96b2c66e242954d8591e7b8ca7b9d6a2a4e1074a. Change-Id: Ie630466ef50e6bcdabf01daff28c283c764aae35
* Include short descriptions for extensions bundled in the releaseMark A. Hershberger2014-01-121-68/+70
| | | | | | | Also fix styling for the list of extensions. Bug: 43817 Change-Id: I5335225683ec8f1c163bb67f478787ebc52ee3a9
* Move closing parenthesis from multi line if and function to own lineumherirrender2013-12-011-2/+2
| | | | | | | | | | | The Line continuation Coding conventions prefers the closing parenthesis on the same line than the beginning curly braces. This is done for ifs and functions. Also move some boolean operator from the end of a line to the beginning and changed some indentation to make the condition hopefully better readable. Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
* Remove poorly-phrased doc comment and the FIXME which went with itTim Starling2013-10-291-2/+1
| | | | Change-Id: I82994ba8f92322b420b4a3fed40d5d579b06a6d2
* Parser::replaceInternalLinks: fix batchingKevin Israel2013-10-231-17/+34
| | | | | | | | | | | | | | | The parser unnecessarily made individual checks for existence of pages that were neither in LinkCache nor linked only with a fragment. A Title::isKnown() call in Parser::replaceInternalLinks2() (added in bca8b8ad7d2f) caused this. Title::isKnown() was used to avoid treating a link to a distinct page as a self-link even when the title happened to match one of the variants returned by Language::autoConvertToAllVariants(). This change fixes the bug by moving the problematic portion of the self-link check into LinkHolderArray::doVariants(). Change-Id: I586e11e8b47308980ea04087ebc4246c397a8f53