Commit graph

20 commits

Author SHA1 Message Date
Matěj Suchánek
7f6323e355 Fix switch-case syntax in ParserOutputAccess
The equality check is unnecessary, the switch-case construct
does it. The code should work the same:
When $useCache is equal to CACHE_SECONDARY, the expression
evaluates to true and so does the loose comparison done by
the switch.
Otherwise it evaluates to false and the case is false, too.

Follow-Up: I0fe275b4991f1bf89c7bb587132bc4fb0ea862e2
Change-Id: I2ded074d4e31d5770c02b4d5ac4acc58b8542ad0
2022-03-14 20:08:44 +00:00
Amir Sarabadani
b6e2a124fb ParserOutputAccess: Check for latest revision when checking for cache
This is similar to the rest of the class, caching if revision is not
specified or it's the latest.

This helps in cases when revision is being passed to getParserOutput()
like FlaggedRevs

Bug: T283029
Change-Id: Ia5c5c112a033944689259c2d2839faf4a8bd90e0
2022-02-17 18:08:03 +01:00
Amir Sarabadani
206f6cbd50 ParserOutputAccess: Add process cache within the service class
This guards against duplicate parses.

These happen when a page is parsed but an extension needs the
ParserOutput again in the same request when it hasn't made into the
ParserCache yet, or if it is considered uncachable. In that case we
still want to allow re-use within the same process.

Bug: T301310
Change-Id: I1ddd967a40b760b1e53f1fd227cb0d0732f78ec1
2022-02-16 12:18:21 +00:00
daniel
c839155dc0 Remove @unstable tag from ParserOutputAccess
ParserOutputAccess was introduced in 1.36, time to call it stable in
1.38.

Change-Id: Idf8928b87e841bc8837df2e56b09841fc104e25f
2021-11-24 09:42:38 +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
jenkins-bot
b3a8ea7076 Merge "Remove 'stubthreshold' from ParserCache key." 2020-12-15 20:21:14 +00:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
Petr Pchelko
9872b627ff Article:view - always try using ParserCache for old revisions.
Bug: T268075
Change-Id: Ie318a6275c1fb5aedff830b72ee838def815e190
2020-12-07 15:18:08 -06:00
Petr Pchelko
235c56d649 Remove 'stubthreshold' from ParserCache key.
Stubthreshold option used to be a cache-varying option,
but in all places where we interact with the ParserCache
we are checking that it's 0 before using the cache.

Instead, we can just remove all the special cases for
stubthreshold option, remove it from cache key and rely
on ParserOptions::isSafeToCache to avoid caching non-default
stubthreshold outputs.

Bug: T264351
Change-Id: Ifaf69a3e651eef21c88da3aa3044b490059958ca
2020-12-07 14:47:05 -06:00
Petr Pchelko
3d6e6a5f70 ParserOutputAccess: don't compate RevisionRecord to int
Change-Id: I2c261328770b9a990fb7221d43dbfe974a7ecfe1
2020-12-03 11:03:45 -06: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
jenkins-bot
6e5c7e97b4 Merge "PoolWorkArticleView: inject logger" 2020-11-18 20:47:06 +00:00
daniel
195bc9715d PoolWorkArticleView: inject logger
Bug: T267832
Change-Id: I7f4763d0e812d076188bb1a4ca2c333f50dffbee
2020-11-18 17:08:37 +01:00
daniel
1dd539f069 ParserOutputAccess: add metrics
Bug: T267832
Change-Id: I49d0bf3de2313babe8ab140855314230ad0af68c
2020-11-17 22:39:30 +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