Commit graph

250 commits

Author SHA1 Message Date
jenkins-bot
14bf85d424 Merge "Hard-deprecate IDatabase parameter for UserIdentity:getActorId()" 2021-02-17 19:41:12 +00:00
Cindy Cicalese
2d302a936e Hard-deprecate IDatabase parameter for UserIdentity:getActorId()
Bug: T273576
Change-Id: I0df4a2749afae74671dc4c49bac4e18309677703
2021-02-17 12:51:02 -05:00
jenkins-bot
5d66187122 Merge "Make WikiPage a (non-proper) PageIdentity" 2021-02-16 15:51:49 +00:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
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
2021-02-11 00:13:52 +00:00
Thiemo Kreuz
947a8cfc00 Use ?? instead of isset/array_key_exists where possible
This patch touches all uncontroversial (I hope) places where a chain
of isset(), array_key_exist() and the ternary ?: operator can be
replaced with the much shorter ?? feature from PHP 7.

?? does the same. It checks if the element before the ?? is set and
not null. When this check fails, the element after the ?? is used.

Change-Id: Id612e2782ae928164b26b6f0de676c6c7d8302f3
2021-02-10 20:32:25 +01:00
Daniel Kinzler
65f89072e3 Make WikiPage a (non-proper) PageIdentity
This is a step towards introducing PageRecord.

We allow WikiPage to be a "non-proper" PageIdentity for now,
but this should be changed to a ProperPageIdentity as soon as
possible.

Bug: T272424
Change-Id: I194c55ec757e655117bccfeb7d6f5d8487b559e5
Signed-off-by: daniel <dkinzler@wikimedia.org>
2021-02-10 11:24:05 +01:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Reedy
eb41565a9a Tests: Start marking some closures as static
Bug: T274036
Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
2021-02-06 19:57:42 +00:00
jenkins-bot
38ca9d704f Merge "Hard deprecate RevisionStore::newMutableRevisionFromArray" 2021-02-04 00:31:11 +00:00
jenkins-bot
a4b551bd31 Merge "Set proper epoch in cache tests." 2021-02-03 22:52:52 +00:00
Peter Ovchyn
e7e0db5b34 Hard deprecate RevisionStore::newMutableRevisionFromArray
Bug: T272560
Depends-On: I171537c3346a7dd4aeb4fc612d7dd9fba5d64679
Change-Id: If8d079a5d0e9bc9103cf4a6893a9c961d2728534
2021-02-03 22:29:44 +00:00
daniel
ece39dbf60 Set proper epoch in cache tests.
Since ConvertibleTimestamp interprets "" as "now", setting the epoch to
"" resulted in the cache expiring after one second. This would cause the
test to fail of the system clock ticket over the second mark before the
cache was accessed, resulting in spurious test failures.

Bug: T271081
Change-Id: I4ffe4570f9a7a1a09460ad00fedc14b17adddf05
2021-02-03 23:08:25 +01:00
jenkins-bot
4829a22684 Merge "Normalize IP addresses before writing/reading actor.actor_name" 2021-01-29 12:17:20 +00:00
Gergő Tisza
16c192f2af
Normalize IP addresses before writing/reading actor.actor_name
This was almost always happening already but handling it in
ActorMigration is less fragile.

Also recover some lost tests.

Bug: T272225
Change-Id: I24c82cfbd40595e79f64c6b0441c2cf789cfbbff
2021-01-26 22:56:30 -08:00
Thiemo Kreuz
b655f382db Remove broken/outdated @param/@throws tags from @dataProviders
My personal best practice is to not document @params when there
is a @dataProvider. I mean, these test…() functions are not
meant to be called from anywhere. They do not really need
documentation. @param tags don't do much but duplicate what the
@dataProvider does. This is error-prone, as demonstrated by the
examples in this patch.

This patch also removes @throws tags from tests. A test…() can
never throw an exception. Otherwise the test would fail.

Most of these are found by the not yet released I10559d8.

Change-Id: I3782bca43f875687cd2be972144a7ab6b298454e
2021-01-21 03:42:42 +00:00
daniel
e9766994e5 WikiPage: add test for invalid titles
WikiPage should not try to create pages with invalid titles. This may
lead to data corruption.

The change in I03969883fc0b326dd2374d7f8e24c1d5a650d5fa should
make the new test pass.

Change-Id: I713c7b14dae86aa7b544bb613e6d5869a049f8b7
2021-01-20 10:14:42 -08:00
daniel
a4ec04c6df WikiPage: deprecated construction on bad titles
WikiPage represents a page that can be created and edited.
WikiPage should not be constructed on Titles that represent things like
special pages or section links. Any such usage should be deprecated.

Bug: T272424
Change-Id: I03969883fc0b326dd2374d7f8e24c1d5a650d5fa
2021-01-20 14:31:11 +01:00
James D. Forrester
a547ef3b9e Revert "Make WikiPage a ProperPageIdentity"
This reverts commit 8f46ef5ff4.

This has seemingly broken FlaggedRevs and thus a bunch of repos.

Bug: T272170
Change-Id: I67de3dbbbc9163aae937f710ecb0e40db0d483a0
2021-01-15 12:30:30 -08:00
James D. Forrester
a8fe6c9841 Revert "Define equality for PageIdentity and LinkTarget"
This reverts commit 36f1adf670.

This has seemingly broken FlaggedRevs and thus a bunch of repos.

Bug: T272170
Change-Id: I26c6fd656c75a6b209fb17965dc9109edf68642b
2021-01-15 12:30:14 -08:00
daniel
36f1adf670 Define equality for PageIdentity and LinkTarget
This allows Title and WikiPage objects to be compared with PageIdentity
and LinkTarget instances consistently.

Change-Id: I1bbd15d17d046359393ecfc1acd2778273260a95
2021-01-15 17:53:28 +01:00
jenkins-bot
9fe9d76577 Merge "Make WikiPage a ProperPageIdentity" 2021-01-15 16:17:44 +00:00
daniel
8f46ef5ff4 Make WikiPage a ProperPageIdentity
This makes it so methods that take a WikiPage can be narrowed to a
PageIdentity, and prepares WikiPage for the introduction of the PageRecord
interface.

Bug: T208776
Change-Id: Iab8bd75a1948873baab9c91c76f966d606b23c0f
2021-01-15 12:34:24 +01:00
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
Máté Szabó
899b6bd721 WikiPage: Add process cache for content model
WikiPage::getContentModel() gets called several times per request via
Action::getActionName(), triggering memcached I/O on each call. Excimer icicle
graphs for index.php indicate about 1.26% of time is spent in this method, so
let's add process caching to avoid redundant memcached fetches on subsequent
invocations.

Change-Id: Icdb9ffb849a0a0a264083957431495f8f4fb783e
2021-01-05 15:43:11 +01:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
jenkins-bot
2697ba639e Merge "WikiPage: add interim replacement for WikiPage::doEditContent() requiring $user" 2020-12-17 15:11:00 +00:00
Petr Pchelko
0eef0a6a3a Article: view from old revision cache - set correct revId.
Bug: T270361
Change-Id: Ice99038df450bb6892a5064b67f3d35f3255267b
2020-12-17 07:22:35 -06:00
DannyS712
25db391d53 ParserOptions: Deprecate fallback to $wgUser
Emit deprecation notices in the constructor
if falling back to $wgUser, and fix core
calls

Bug: T246861
Depends-On: I51117931d527a3bdda468b48de577a7faafbcd69
Change-Id: Ibd0a8ffd0494c17a378cc43e6b6164166130adf4
2020-12-16 09:03:29 +00:00
Taavi Väänänen
0ffed5799d WikiPage: add interim replacement for WikiPage::doEditContent() requiring $user
This patch adds a method named WikiPage::doUserEditContent() as an interim
replacement to existing deprecated ::doEditContent() method. The new
method requires $user to be passed as a parameter and no longer supports
passing in the unused $serialFormat parameter. The new method otherwise
behaves identically compared to the old doEditContent() method.

Bug: T255507
Change-Id: Ibc0052b27a6d3cda3eb9663b95b4f45116dcc9f1
2020-12-15 08:59:57 +02:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
DannyS712
649d20f6be Add dependency injection to RevDelList classes
Bug: T268713
Change-Id: I9ee516f4aa35e493a630299e8ba2c60edd4f06ba
2020-12-11 21:43:23 +00:00
Petr Pchelko
7cf60852fa Article::view - remove the old subtitle from doOutputFromParserCache.
The method is called from two places:
- For new revision ParserCache, when the subtitle doesn't need
to be applied. That call is protected by !oldid check
- For old revision cache, when subtitle is already applied before
checking the cache. So, no need to set it.

Bug: T269727
Change-Id: Ibec845ccfe43ae2cb4bbe0152c932cb74f3cef4b
2020-12-08 21:52:11 -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
jenkins-bot
2be635539f Merge "ParserOutputAccess: cache ouput for old revisions" 2020-11-18 19:52:10 +00:00
jenkins-bot
a4d2077424 Merge "Drop Article::getEmptyPageParserOutput" 2020-11-18 19:21:15 +00: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
jenkins-bot
4e46e84202 Merge "Clean up PoolWorkArticleView" 2020-11-16 14:19:42 +00: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
Petr Pchelko
890452301d Drop Article::getEmptyPageParserOutput
The only place where this was used is to show the system
message contents on a missing article page in NS_MEDIAWIKI
namespace, which is much easier done without MessageContent.

The override in ImagePage is a guaranteed no-op, cause we can't
have ImagePage for NS_MEDIAWIKI namespace.

These were the only two places where this method was used across
codesearch.

Change-Id: I9b9be61eaff6d153fbd2381c91c598b3421e5ea2
2020-11-15 08:57:24 -07:00
jenkins-bot
687fbf95ca Merge "Display error message without constructing a fake revision." 2020-11-13 18:05:08 +00:00
Cindy Cicalese
39707515b0 Display error message without constructing a fake revision.
Change-Id: I67e32e73e77c335dcfeacfb045918133fd4d3870
2020-11-13 12:09:57 -05:00
Umherirrender
9fb6d107ba Improve docs about @param/@return object $row to stdClass
Change-Id: I743d992db703f2b46b6e3abf80c14d026c6599f4
2020-11-13 00:08:21 +01:00
Petr Pchelko
7c68ae9296 Safe ParserOutput extension data and JsonUnserializable helper.
One major difference with what we've had before is that now we
actually write class names into the serialization - given that
this new mechanism is extencible, we can't establish any kind
of mapping of allowed classes. I do not think it's a problem
though.

Bug: T264394
Change-Id: Ia152f3b76b967aabde2d8a182e3aec7d3002e5ea
2020-11-10 11:21:09 -07: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