aboutsummaryrefslogtreecommitdiffstats
path: root/includes/poolcounter
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge "Fix various documentation related to null types (part II)"jenkins-bot2022-03-091-3/+3
|\ \
| * | Fix various documentation related to null types (part II)Umherirrender2022-03-081-3/+3
| |/ | | | | | | | | | | | | | | | | The functions returning null or the class property is set explict null. Some function should not accept null or return null. Found by phan strict checks Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
* / Fix various documentation related to scalar typesUmherirrender2022-03-091-1/+1
|/ | | | | | Found by phan strict checks Change-Id: If41d16b473baddd92cc4261cdc2bfbe65fedcb19
* Add explicit casts between scalar typesUmherirrender2022-03-011-2/+2
| | | | | | | | | | | | | | | * Some functions accept only string, cast ints and floats to string * After preg_matches or explode() casts numbers to int to do maths * Cast unix timestamps to int to do maths * Cast return values from timestamp format function to int * Cast bitwise operator to bool when needed as bool * php internal functions like floor/round/ceil documented to return float, most cases the result is used as int, added casts Found by phan strict checks Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
* Try not to discard Excimer timeout exceptionsTim Starling2022-02-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Don't catch and discard exceptions from the RequestTimeout library, except when the exception is properly handled and the code seems to be trying to wrap things up. In most cases the exception is rethrown. Ideally it should instead be done by narrowing the catch, and this was feasible in a few cases. But sometimes the exception being caught is an instance of the base class (notably DateTime::__construct()). Often Exception is the root of the hierarchy of exceptions being thrown and so is the obvious catch-all. Notes on specific callers: * In the case of ResourceLoader::respond(), exceptions were caught for API correctness, but processing continued. I added an outer try block for timeout handling so that termination would be more prompt. * In LCStoreCDB the Exception being caught was Cdb\Exception not \Exception. I added an alias to avoid confusion. * In ImageGallery I added a special exception class. * In Message::__toString() the rationale for catching disappears in PHP 7.4.0+, so I added a PHP version check. * In PoolCounterRedis, let the shutdown function do its thing, but rethrow the exception for logging. Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
* Remove or replace usages of "sane"Reedy2021-11-221-2/+2
| | | | | Bug: T254646 Change-Id: I096b2cf738a1395a14f1d47bcbed0c2c686c2581
* Remove or replace usages of "sanity"Reedy2021-11-191-4/+4
| | | | | Bug: T254646 Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
* doc: Cleanup @param documentationUmherirrender2021-11-041-1/+1
| | | | | | No extra sign needed between variable and description Change-Id: Iaaaf62a3ffba7967aef8c31b121121b2830b74c4
* Add slow-parsoid log channelTim Starling2021-09-151-2/+1
| | | | | | | By analogy with slow-parse.log. Also, I fixed the log message so that it has the full title in it. Change-Id: Icaeb6f002c5c2a676467d4c760f99cb2676ad73b
* Add comment to fall-through cases in switchUmherirrender2021-04-151-1/+1
| | | | | | | | Fix new coming sniff PSR2.ControlStructures.SwitchDeclaration.TerminatingComment Bug: T182546 Change-Id: I3f8d43c730981d8faaa72910d7f3b58a14a8372f
* Convert ParserOutputAccess to PageRecord.Petr Pchelko2021-04-051-6/+15
| | | | | | | | | | | | Still needs to downcast to WikiPage in 2 places: 1. To check get a ContentHandler and check if content model is cacheable. We probably should just make all content models cacheable. 2. To call WikiPage::triggerOpportunisticLinksUpdate. I have an elaborate plan for this one, but it will be done separately. Change-Id: Ifd9ab0155dc1fad0c1608dafea05d16292afd057
* Introduce RevisionOutputCachedaniel2020-12-141-98/+10
| | | | | Bug: T267981 Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
* Make ParserCache respect ParserOptions::isSafeToCachePetr Pchelko2020-12-021-1/+12
| | | | | Bug: T269154 Change-Id: I8e9ecd2787aa8d172e708ba64ea936e63fbc6b36
* PoolWorkArticleViewOld: use WANObjectCachedaniel2020-11-301-3/+3
| | | | | | | Use WANObjectCache instead of the local cluster object cache. Bug: T268278 Change-Id: Ic16feffecaf4b75c284c6ef34de42ac113e625f8
* Introduce JsonCodec to help with serialization/deserializationPetr Pchelko2020-11-191-32/+13
| | | | Change-Id: I5433090ae8e2b3f2a4590cc404baf838025546ce
* PoolWorkArticleView: inject loggerdaniel2020-11-183-25/+55
| | | | | Bug: T267832 Change-Id: I7f4763d0e812d076188bb1a4ca2c333f50dffbee
* ParserOutputAccess: cache ouput for old revisionsdaniel2020-11-171-0/+171
| | | | | | | | DEPLOY: Set $wgOldRevisionParserCacheExpireTime = 0 in production first! Bug: T267832 Depends-On: I3c73f5d9f6a54e2736600e8f9506659a3fb0e7f6 Change-Id: I0fe275b4991f1bf89c7bb587132bc4fb0ea862e2
* Extract PoolWorlArticleViewCurrentdaniel2020-11-172-104/+186
| | | | | | | | | | | Extracts a specialized subclass for rendering the current revision from PoolWorlArticleView, which then no longer knowes about caching. In the next step, we will add a subclass that implements caching for old revisions. Bug: T267832 Change-Id: I56fb365962951e6c723a01cf9243dbc0094b5581
* Clean up PoolWorkArticleViewdaniel2020-11-161-102/+35
| | | | | | | | | | | | | | | | | | | | PoolWorkArticleView needs some cleanup before we can make it cache output for old revisiosn (T244058). This patch does doe following: * apply dependency injection * remove backwards compatibility code for legacy constructor calls * mark PoolWorkArticleView as @internal (unused in extensions) * remove audience check (to be done by caller) * no longer set $wgUseFileCache to false. For $wgUseFileCache, it seems like this has had no effect for a long time. It would be set to false only on a cache miss during a page view. But the file cache is only updated via HtmlCacheUpdater on edit and purge. Bug: T244058 Change-Id: Ief467562af0aa2f88ff7b42469d0273d2a1dcf7a
* Introduce ParserOutputAccessdaniel2020-11-102-2/+18
| | | | | | | | | | | | | Encapsulate logic for getting rendered page content, for any revision, with caching and pooling hidden away. Introducing such a service object will also give us a leverage point for supporting output transformations. Output transformations are currently implemented partially in ParserOutput, partially in Parser, and partially duplicated in Parsoid. Bug: T267234 Change-Id: I566d7a7936633823ba68b5aecbc8c2d88949b4f8
* build: Updating mediawiki/mediawiki-codesniffer to 32.0.0Umherirrender2020-10-281-1/+1
| | | | | | | Exclude failing sniff to fix in follow ups Includes some simply fix, most are autofix Change-Id: I5bb4743f08618bb6226bc2a4cc7f4d73a7ad142d
* Deprecate ParserCache::getKey and replace it with getMetadataPetr Pchelko2020-10-131-5/+4
| | | | | Bug: T263689 Change-Id: I4a71e5a7eb1c25cd53b857c115883cd00160736b
* Add message text to `slow-parse` log entriesDannyS7122020-10-131-1/+1
| | | | | | | | Currently, it just shows the time and the title, and unless someone looks for which channel the message came in there is no context for the text Change-Id: Ib1edee250d044a28b1ed4c950da3a1ae85c44d06
* Add doc comment for PoolCounter::isFastStaleEnabled()Tim Starling2020-09-171-0/+6
| | | | Change-Id: Ie606b0540b830e64073c44eb33990006a7c5f303
* Return directly from within try/finally blockUmherirrender2020-07-201-2/+1
| | | | | | | | | | | | It is good code style to return a variable from the same scope as it is definied and not from a level deeper. For try/finally blocks this does not change the behaviour because the finally block is executed if the scope is leaved, normally or by return or by thrown exception. This helps static code analyzer like phan to understand the code better. Change-Id: Ib947e58adb3676b1d69507a15ea44d93c5a9973d
* Replace "@stable for calling" by "@stable to call"daniel2020-07-131-1/+1
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
* Mark additional classes as newable for now.daniel2020-07-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | The following glasses are marked as newable per the Stable Interface Policy, even though logically, they should not be newable. This is done for classes that are currently instantiated by extensions, and lack an alternative. A better way for obtaining an instance of these classes should be created in the future. At that point, direct instantiation should be deprecated and replaced. - includes/ApiMain.php - needs factory - includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern - includes/GitInfo.php - should become a stateless service - includes/logging/LogPage.php - should become a stateless service or use command pattern - includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern - includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory - includes/context/RequestContext.php - needs to be narrowed down, and should use a factory - includes/search/SearchHighlighter.php - should have a factory - includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory - includes/user/User.php - should at least get a factory method for anons - includes/diff/Diff.php: needs a TextDiffGenerator service or a factory - includes/EditPage.php: needs a factory Bug: T247862 Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
* Fast stale ParserCache responsesTim Starling2020-06-056-23/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If PoolCounter acquisition would block and a stale ParserCache entry is available, deliver it immediately rather than waiting for the lock. This should avoid PoolCounter contention on heavily edited pages. * Add a fastStale pool option to toggle the feature. False by default but I'll set the default to true in a followup commit. * Add a $timeout parameter to PoolCounter::acquireForMe() and acquireForAnyone(). This requires a simultaneous update to the PoolCounter extension. * In the Redis implementation, use the requested timeout for blPop() but use the configured timeout for data structure cleanup and item expiry. * Add a boolean $fast parameter to fallback() which tells the subclass whether it is being called in the fast or slow mode. No extensions in CodeSearch extend PoolCounterWork directly so this should not cause a fatal. * Pass through the $fast parameter in PoolCounterWorkViaCallback * In PoolWorkArticleView, use the $fast flag to decide whether to check the ChronologyProtector touched timestamp. * Add $wgCdnMaxageStale by analogy with $wgCdnMaxageLagged, which controls the CC:s-maxage when sending a stale ParserOutput. * Fix the documented type of the timeout. It really should be a float, but locks.c will treat non-integers as zero. A simultaneous update to the PoolCounter extension is required. Bug: T250248 Change-Id: I1f410cd5d83588e584b6d27d2e106465f0fad23e
* Remove terminating line breaks from debug messagesTim Starling2020-06-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | A terminating line break has not been required in wfDebug() since 2014, however no migration was done. Some of these line breaks found their way into LoggerInterface::debug() calls, where they mess up the formatting of the debug log. So, remove terminating line breaks from wfDebug() and LoggerInterface::debug() calls. Also: * Fix the stripping of leading line breaks from the log header emitted by Setup.php. This feature, accidentally broken in 2014, allows requests to be distinguished in the log file. * Avoid using the global variable $self. * Move the logging of the client IP back to Setup.php. It was moved to WebRequest in the hopes that it would not always be needed, however $wgRequest->getIP() is now called unconditionally a few lines up in Setup.php. This means that it is put in its proper place after the "start request" message. * Wrap the log header code in a closure so that variables like $name do not leak into global scope. * In Linker.php, remove a few instances of an unnecessary second parameter to wfDebug(). Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
* Fix even more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-162-11/+11
| | | | Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
* Add missing visibility on methods of class PoolCounterRedisUmherirrender2020-05-101-3/+3
| | | | Change-Id: I0597aabd516e2b0b205a64c10c998052eb6d6864
* Replace uses and hard deprecate Article:: and WikiPage::getRevisionDannyS7122020-04-201-5/+13
| | | | | | Bug: T250532 Bug: T239975 Change-Id: Ic8f2baa0ac805d5196a7107bdc7a1abb36eba139
* poolcounter: Call poolCounter->release on exception and add tests for ↵Peter Ovchyn2020-04-102-6/+11
| | | | | | | | | PoolCounterWork Add type hitting to correctly cover object construction. Bug: T249531 Change-Id: I20c61a08813cf564e07dc3a8272727a1e1043348
* Set method visibility for various constructorsUmherirrender2019-12-031-1/+1
| | | | Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
* Unsuppress another phan issue (part 7)Daimona Eaytoy2019-09-031-0/+4
| | | | | | | Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
* rdbms: fix some phpstorm warnings database classesAaron Schulz2019-07-131-0/+2
| | | | Change-Id: Ib3b8aaadda8101ed82158b1260f10f6d7be16783
* Avoid/Replace usage of deprecated `wfMemcKey()` functionDerick Alangi2019-05-021-1/+3
| | | | | | | This global function was deprecated in 1.30 and is replaced with the use of `ObjectCache::getLocalClusterInstance()->makeKey()`. Change-Id: Ic08b53111be4374a973e08c2ed68224bfa922fa8
* Rename PoolCounter_Stub to PoolCounterNullUmherirrender2019-03-242-22/+46
| | | | | | | | Also move to own file Remove "Stub", because it refers a php concept, which is not used here Change-Id: Ife952901b5ad8e4a408d229ee72de953a9acc220
* Re-namespace RevisionStore and RevisionRecord classesBrad Jorsch2018-10-091-4/+4
| | | | | | | | | | | | | | | | | | | During development a lot of classes were placed in MediaWiki\Storage\. The precedent set would mean that every class relating to something stored in a database table, plus all related value classes and such, would go into that namespace. Let's put them into MediaWiki\Revision\ instead. Then future classes related to the 'page' table can go into MediaWiki\Page\, future classes related to the 'user' table can go into MediaWiki\User\, and so on. Note I didn't move DerivedPageDataUpdater, PageUpdateException, PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\ instead. Bug: T204158 Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
* Add audience parameter to PoolWorkArticleViewGergő Tisza2018-10-021-3/+8
| | | | | | | | | | The old behavior was that the audience was RAW if the revision object parameter got passed in, otherwise PUBLIC. This was undocumented and not used outside core; this patch gets rid of it in favor of an explicit argument. Bug: T205578 Change-Id: Ic7cdb38f658f6d85c48ff13c7f84c64a45c9b1ee
* Add constant for the name of the 'main' slot for MCRGergő Tisza2018-09-241-1/+2
| | | | | Bug: T202142 Change-Id: I97a74e5a029b014f3c2195188936d5c8233c1b7f
* Use RevisionRenderer for rendering ParserOutputdaniel2018-09-111-26/+69
| | | | | | Bug: T174035 Bug: T174036 Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
* Fix PhanTypeMismatchDeclaredParamUmherirrender2018-07-071-1/+1
| | | | | | Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
* Get rid of call_user_func(_array)(), part 3Max Semenik2018-06-101-4/+4
| | | | | | Also cleaned up nearby code in a couple places. Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
* Rewrite HashRing to use consistent hashingAaron Schulz2018-06-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | This scheme avoids disruptive re-hashing when a node is ejected; only the adjectent clockwise sector is affected, the later taking responsibility for the former. Addition of new nodes is likewise less disruptive. When used with MD5, this maps keys the same as libketama. Also: * Make HashRing::getLocations() faster by guessing the sector list index and moving clockwise/counter-clockwise. * Made HashRing Serializable for more robust storage. * Allow for different hash functions to be specified. Note: * This makes PoolCounterRedis use the new hash scheme. * Likewise for JobQueueFederated (for job de-duplication). Switching from one mode to the other will cause some of duplicated effort from old jobs only temporarily. Change-Id: Iff432a4e5dc3fb40b2dda70fb3dbe9dda0b74933
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-3/+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
* poolcounter: Fix type hint for PoolWorkArticleView::getParserOutputThiemo Mättig2018-01-241-1/+1
| | | | Change-Id: Ib6a71e198481cf2a0230b3f8721c019ef3c7288c
* build: Updating mediawiki/mediawiki-codesniffer to 15.0.0Umherirrender2018-01-012-4/+3
| | | | | | | | | | | | | Clean up use of @codingStandardsIgnore - @codingStandardsIgnoreFile -> phpcs:ignoreFile - @codingStandardsIgnoreLine -> phpcs:ignore - @codingStandardsIgnoreStart -> phpcs:disable - @codingStandardsIgnoreEnd -> phpcs:enable For phpcs:disable always the necessary sniffs are provided. Some start/end pairs are changed to line ignore Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
* Avoid using the deprecated ParserCache::singleton()Kunal Mehta2017-09-091-4/+9
| | | | Change-Id: I0da6d9cbfad26c89bf5dab564071ef97acaf44f9
* Remove "@author Aaron Schulz" annotationsAaron Schulz2017-06-271-1/+0
| | | | | Bug: T139301 Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489