Commit graph

76 commits

Author SHA1 Message Date
Umherirrender
cf541752e0 Add comment to fall-through cases in switch
Fix new coming sniff
PSR2.ControlStructures.SwitchDeclaration.TerminatingComment

Bug: T182546
Change-Id: I3f8d43c730981d8faaa72910d7f3b58a14a8372f
2021-04-15 17:31:12 +00:00
Petr Pchelko
cd66d7c335 Convert ParserOutputAccess to PageRecord.
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
2021-04-05 07:46:34 -06:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
Petr Pchelko
4417b13d58 Make ParserCache respect ParserOptions::isSafeToCache
Bug: T269154
Change-Id: I8e9ecd2787aa8d172e708ba64ea936e63fbc6b36
2020-12-02 14:02:36 -06:00
daniel
2c7ba6f62b PoolWorkArticleViewOld: use WANObjectCache
Use WANObjectCache instead of the local cluster object cache.

Bug: T268278
Change-Id: Ic16feffecaf4b75c284c6ef34de42ac113e625f8
2020-11-30 16:38:56 +00:00
Petr Pchelko
dbdc2a3cd3 Introduce JsonCodec to help with serialization/deserialization
Change-Id: I5433090ae8e2b3f2a4590cc404baf838025546ce
2020-11-19 08:32:21 -07:00
daniel
195bc9715d PoolWorkArticleView: inject logger
Bug: T267832
Change-Id: I7f4763d0e812d076188bb1a4ca2c333f50dffbee
2020-11-18 17:08:37 +01:00
daniel
a2ae4192c0 ParserOutputAccess: cache ouput for old revisions
DEPLOY: Set $wgOldRevisionParserCacheExpireTime = 0 in production first!

Bug: T267832
Depends-On: I3c73f5d9f6a54e2736600e8f9506659a3fb0e7f6
Change-Id: I0fe275b4991f1bf89c7bb587132bc4fb0ea862e2
2020-11-17 20:52:35 +00:00
daniel
ed41864370 Extract PoolWorlArticleViewCurrent
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
2020-11-17 20:17:02 +01:00
daniel
175d548e61 Clean up PoolWorkArticleView
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
2020-11-16 12:06:20 +01:00
daniel
67d0986211 Introduce ParserOutputAccess
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
2020-11-10 15:12:12 +01:00
Umherirrender
d621adbcb6 build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
Exclude failing sniff to fix in follow ups
Includes some simply fix, most are autofix

Change-Id: I5bb4743f08618bb6226bc2a4cc7f4d73a7ad142d
2020-10-28 20:06:22 +00:00
Petr Pchelko
13574e8404 Deprecate ParserCache::getKey and replace it with getMetadata
Bug: T263689
Change-Id: I4a71e5a7eb1c25cd53b857c115883cd00160736b
2020-10-13 08:31:22 -07:00
DannyS712
551e2d50f1 Add message text to slow-parse log entries
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
2020-10-13 06:44:37 +00:00
Tim Starling
0d9c7574dc Add doc comment for PoolCounter::isFastStaleEnabled()
Change-Id: Ie606b0540b830e64073c44eb33990006a7c5f303
2020-09-17 22:07:15 +00:00
Umherirrender
0d706ed09e Return directly from within try/finally block
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
2020-07-20 15:54:32 +00:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
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
2020-07-13 08:55:28 +00:00
daniel
128565505c Mark additional classes as newable for now.
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
2020-07-08 18:06:12 +02:00
Tim Starling
7f710a514a Fast stale ParserCache responses
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
2020-06-05 16:24:22 +10:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
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
2020-06-03 12:01:16 +10:00
Reedy
b80a9f4f6a Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
2020-05-16 00:51:14 +01:00
Umherirrender
a617735f5a Add missing visibility on methods of class PoolCounterRedis
Change-Id: I0597aabd516e2b0b205a64c10c998052eb6d6864
2020-05-10 22:13:49 +00:00
DannyS712
4721717527 Replace uses and hard deprecate Article:: and WikiPage::getRevision
Bug: T250532
Bug: T239975
Change-Id: Ic8f2baa0ac805d5196a7107bdc7a1abb36eba139
2020-04-20 23:06:48 +00:00
Peter Ovchyn
212f155abb poolcounter: Call poolCounter->release on exception and add tests for PoolCounterWork
Add type hitting to correctly cover object construction.

Bug: T249531
Change-Id: I20c61a08813cf564e07dc3a8272727a1e1043348
2020-04-10 12:51:25 +03:00
Umherirrender
0688dd7c6d Set method visibility for various constructors
Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
2019-12-03 20:17:30 +01:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
Aaron Schulz
0848e9049c rdbms: fix some phpstorm warnings database classes
Change-Id: Ib3b8aaadda8101ed82158b1260f10f6d7be16783
2019-07-13 21:49:51 +00:00
Derick Alangi
1b9ea4d1bf Avoid/Replace usage of deprecated wfMemcKey() function
This global function was deprecated in 1.30 and is replaced with
the use of `ObjectCache::getLocalClusterInstance()->makeKey()`.

Change-Id: Ic08b53111be4374a973e08c2ed68224bfa922fa8
2019-05-02 14:27:31 +00:00
Umherirrender
c71a50e2a0 Rename PoolCounter_Stub to PoolCounterNull
Also move to own file
Remove "Stub", because it refers a php concept,
which is not used here

Change-Id: Ife952901b5ad8e4a408d229ee72de953a9acc220
2019-03-24 22:44:46 +01:00
Brad Jorsch
dff469a408 Re-namespace RevisionStore and RevisionRecord classes
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
2018-10-09 10:22:48 -04:00
Gergő Tisza
5174fa8364
Add audience parameter to PoolWorkArticleView
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
2018-10-02 03:53:28 -07:00
Gergő Tisza
6e8d39c6e7
Add constant for the name of the 'main' slot for MCR
Bug: T202142
Change-Id: I97a74e5a029b014f3c2195188936d5c8233c1b7f
2018-09-24 16:52:12 -07:00
daniel
4835a75ec5 Use RevisionRenderer for rendering ParserOutput
Bug: T174035
Bug: T174036
Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
2018-09-11 15:25:39 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Max Semenik
1e680456b4 Get rid of call_user_func(_array)(), part 3
Also cleaned up nearby code in a couple places.

Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
2018-06-10 02:21:24 +00:00
Aaron Schulz
f2e6543c46 Rewrite HashRing to use consistent hashing
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
2018-06-07 03:36:22 -07:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
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
2018-05-30 18:06:13 -07:00
Thiemo Mättig
7d0d9815d3 poolcounter: Fix type hint for PoolWorkArticleView::getParserOutput
Change-Id: Ib6a71e198481cf2a0230b3f8721c019ef3c7288c
2018-01-24 18:41:52 +00:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
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
2018-01-01 14:10:16 +01:00
Kunal Mehta
1fd095ec1c Avoid using the deprecated ParserCache::singleton()
Change-Id: I0da6d9cbfad26c89bf5dab564071ef97acaf44f9
2017-09-09 14:20:10 -07:00
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Kunal Mehta
77b2cf831b Include numerical namespace in slow-parse.log
This makes it easier to sort by namespace rather than trying to parse it
out of the title.

Change-Id: I946cb00548bcb69bd2be98c15a9f1e02e546fa24
2016-12-09 23:18:45 +00:00
Aaron Schulz
3740e4eed2 Use @lang tags for Lua scripts
Change-Id: Ifdbff687539078b375330ebe3a1493b281e5c518
2016-09-25 11:50:16 -07:00
Aaron Schulz
10593ffaab Move RedisConnectionPool to /libs/redis
Change-Id: Ied4a85d7172ab76b90f6d9ce4d47a83c3fd7d111
2016-09-23 00:20:19 -07:00
James D. Forrester
960e4d09ca Documentation: Replace misuse of 'later' when we meant 'latter'
Change-Id: I01bfdb8e0bfaa132533732873f7c840cea7935eb
2016-09-07 13:13:42 -07:00
Aaron Schulz
39ed32922e Include type in hashKeyIntoSlots()
Otherwise, all pool types that use slots will collide
due to the slotted keys not using a type prefix.

Bug: T134144
Change-Id: Ib367fedf2cfb7fecc290206e69e0d105276e96e6
2016-05-09 16:54:51 -07:00
Aaron Schulz
58bae669bc Clean up PoolWorkArticleView type hints and fix IDEA errors
All callers pass a WikiPage here already.

Change-Id: I6a17bf52fb2547729c6a1fa40704f1c9efe28b12
2016-05-03 01:47:36 -07:00
Ricordisamoa
1617e7822e Always use 'bool' instead of 'boolean' in Doxygen tags
Just like commit f86a5590aa

Change-Id: Ic9d08bca6524d6bb4baf5170c081ad0f3d738e28
2016-03-24 09:44:09 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00