Commit graph

442 commits

Author SHA1 Message Date
Thiemo Kreuz
c3dfa88966 Add missing empty lines between methods
This might hint at an edge-case in the PHP CodeSniffer sniff that should
detect if methods are separated by a single empty line. Feel free to
investigate. I, personally, can't invest more time in this than
suggesting this quick fix.

Change-Id: Ib3c60eac76f255b4fe929f7933de256222716576
2019-01-15 19:14:35 +00:00
daniel
f4f66368e4 Revision: Assert that $mRecord is never null in Revision
Bug: T187153
Change-Id: I828954855aa24114ec756e45d4dfe1468b2efa27
2018-12-21 23:09:11 +00:00
daniel
7d8a959543 Allow getRevisionText to function without the text table.
Without this patch, getRevisionText would fail silently (by
returning false) when the text table no longer gets joined,
due to the switch to the new MCR schema.

Bug: T205808
Change-Id: Iffc25c82a5d2b865c28070c76156d39d390cc675
2018-10-17 10:54:39 -04:00
Brad Jorsch
993baa3493 ActorMigration: Remove possibility of read-both
When this was originally written, the plan was to read both the old and
new fields during the transition period, while stopping writes to them
midway through. It turns out that the WHERE conditions to do read-both
correctly are generally not handled well by the database and working
around that would require a lot of complicated code (see what's being
removed from ApiQueryUserContribs here, for example).

We can simplify things greatly by instead having it write both fields
during the transition period, reading from the old for the first part
and the new for the second part, as is being done for MCR.

Bug: T204669
Change-Id: I4764c1c7883dc1003cb12729455c8107319f70b1
Depends-On: I845f6ae462f2539ebd35cbb5f2ca8b5714e2c1fb
Depends-On: I88b31b977543fdbdf69f8c1158e77e448df94e11
2018-10-11 12:12:00 +11: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
daniel
539cb2816a Avoid fatal when finding no base revision for a null revision.
Bug: T205675
Change-Id: Iae67649a1be9597086033ad34d9d00556ba35730
2018-10-04 19:54:31 +02: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
9bd162dce2 [MCR] Set MCR migration stage to write-both/read-new.
This patch exists to see if CI passes with
$wgMultiContentRevisionSchemaMigrationStage set to
SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW.

NOTE: verify that $wgMultiContentRevisionSchemaMigrationStage
is explicitly set toSCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
in production config (T197816) before merging this.

Bug: T198561
Depends-On: Ib718868d2c768b6ea851355eef047bc0e6593495
Change-Id: I15989adae2b5916577d164c50d7da88774e49324
2018-09-11 12:27:42 +02:00
petarpetkovic
3f60fb5ad1 Remove duplicated article usages
Bug: T201491
Change-Id: I72b1e7609b49b9bf182c0872f8b780d9e9e08695
2018-08-09 10:29:38 +02:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
jenkins-bot
9d914bed08 Merge "Blob can't be false" 2018-06-20 20:04:10 +00:00
daniel
564257dc50 Blob can't be false
Change-Id: Ic06fcfaac71128c0ff7e9079685eac18206f2004
2018-06-20 17:32:35 +02:00
jenkins-bot
284bc0b5eb Merge "When encountering bad blobs, log the text row id." 2018-06-19 12:32:44 +00:00
daniel
2f9e892c74 When encountering bad blobs, log the text row id.
Change-Id: Ie7c932f229854fd3582d507fa7cc154ffdd21f55
2018-06-19 13:59:01 +02:00
jenkins-bot
067b225664 Merge "Provide backwards compatibility for RevisionInsertComplete hook." 2018-06-13 20:07:02 +00:00
daniel
2105426eed Provide backwards compatibility for RevisionInsertComplete hook.
Call the RevisionInsertComplete from RevisionStore for now, so extensions
that still rely on this hook don't break when more code uses RevisionStore
instead of Revision.

This specifically avoid breaking EventBus and Translate when If610c68f491
is merged.

Change-Id: I3356c8250d7934e0089d4627fdebddf7983f194f
2018-06-13 18:24:00 +00: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
Matthew Bowker
318706a27c Remove three deprecated functions from the Revision class.
This commit removes Revision::getRawUser(), Revision::getRawUserText(), and Revision::getRawComment(). All three were deprecated in 1.25 and are only used in unmaintained extensions.

Bug: T61113
Change-Id: I729985b791df89bc7e577fb823e647c48549e637
2018-05-02 19:51:04 +00:00
jenkins-bot
2224e31507 Merge "Drop archive.ar_text and ar_flags" 2018-04-23 20:15:26 +00:00
daniel
1b115fd022 Introduce SqlBlobStore::makeAddressFromTextId
This introduces a convenience method for constructing a blob address
from a text ID. It's the inverse of SqlBlobStore::getTextIdFromAddress

Change-Id: I31b3ee5e40185c754fb2c119eb5edc50b903f5dc
2018-04-19 17:23:59 +00:00
Brad Jorsch
21c6ae1163 Drop archive.ar_text and ar_flags
This should have been done long ago. Now it is being done.

This also changes ar_text_id to NOT NULL, since it should never be null
anymore, and DEFAULT 0 in preparation for MCR stopping writing it.

Bug: T33223
Change-Id: I18f1c740b7537c7dc3cfeba9b241d0a9f31caa34
2018-04-03 12:54:27 -04:00
jenkins-bot
a2c8c29694 Merge "Revert "Log the reason why revision->getContent() returns null"" 2018-03-05 18:51:58 +00:00
Sbisson
b33148f7d6 Revert "Log the reason why revision->getContent() returns null"
This reverts commit 8eb00f1584.

Change-Id: Id14fd26845349f8aca110ac1bad0598770122f25
2018-03-05 15:17:46 +00:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
jenkins-bot
803f3867b7 Merge "Log the reason why revision->getContent() returns null" 2018-02-14 18:30:48 +00:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
addshore
d3c721fd28 Use RevisionLookup and RevisionFactory interfaces in Revision
Lets not depend on the big blob that is RevisionStore.
Try to bind to the nice interfaces that we have where possible.

In the future RevisionStore should be split up further into
it's individual interfaces.

It looks like there are some more methods which should be moved
to both RevisionLookup and RevisionFactory.
See draft:
I214c5952d4a0fad55ff4116e90eab9ac3ba54fd3

Change-Id: I8df61374e24abcf4a7e38e53647489b8ecc1fd77
2018-01-24 14:11:31 -08:00
Stephane Bisson
8eb00f1584 Log the reason why revision->getContent() returns null
In the context of WikiPage->doEditUpdates(), when $revision->getContent()
returns null, $this->prepareContentForEdit() fails because it expects
something that implements 'Content' as its first argument but null is given.

This problem happens during Flow beta feature opt-out. I hope
this logging is not too spammy and helps shed light on the Flow
problem.

Bug: T184670
Change-Id: If06b8fda3657cae2eb23821f35e5b87919ceb615
2018-01-23 13:41:04 -08:00
jenkins-bot
8d6cb3df87 Merge "Make Revision::__construct work with bad page ID" 2018-01-11 16:33:34 +00:00
daniel
4589f4d781 Make Revision::__construct work with bad page ID
For backwards-copatibility, we need to be able to construct a Revision
object even for bad page IDs.

Bug: T184689
Change-Id: I18c823d7b72504447982364d581b34e98924b67f
2018-01-11 17:03:48 +01:00
jenkins-bot
1975297654 Merge "Handle failure to load content in Revision getSize, etc" 2018-01-11 14:50:00 +00:00
daniel
04bac0dee1 Handle failure to load content in Revision getSize, etc
The Revision class used to just return null if size or hsash were unknown
and could nto be determined. This patch restores this behavior by
catching any RevisionAccessExceptions raised by RevisionRecord when
failing to load content.

Bug: T184693
Bug: T184690
Change-Id: I393ea19b9fb48219583fc65ce81ea14d8d0a2357
2018-01-11 15:23:03 +01:00
addshore
54f0872c7f Revision::newNullRevision don't pass null to RevisionStore
RevisionStore::newNullRevision must be passed a Title object when
being used, passing null will result in a fatal.

Title::newFromID can return null, so check and return null early if we
have no Title object.

Also use Title::GAID_FOR_UPDATE for a higher chance of getting a Title.
Prior to the Revision overhaul newNullRevision would have always done a
select from master, it is documented as accepting $dbw and also passed
FOR UPDATE as an option to selectRow.

Bug: T184687
Change-Id: If1f99d091ab9cd37d514a4f4cbf3c28b64426cb7
2018-01-11 09:22:16 +00:00
addshore
3e2fdb71ed Revert "Revert "[MCR] Add and use $title param to RevisionStoregetPrevious/Next""
This is a partial revert of a revert that reverted a fix believed to
have had its underlying issue fixed in:
https://gerrit.wikimedia.org/r/#/c/400577/

The compat layer (Revision), now passes a Title object into the
RevisionStore, and this title is used to construct the Record and
also any new Revision objects.

Bug: T184559
Bug: T183548
Change-Id: Id073265c173f60aa8c456550fdb4bb5196013be8
2018-01-10 17:05:53 +00:00
daniel
6d52a7241a [MCR] Improve documentation and method naming on Revision and RevisionStore.
Change-Id: I3b049acff9313814a4ac448289d1aef88cb7f9df
2018-01-08 12:50:10 +00:00
Umherirrender
23ef520a1c Improve some parameter docs
Change-Id: I31e983d7ac287158101b18ad95779d83537302a2
2018-01-07 11:39:08 +01:00
addshore
03f69062d5 Pass $title to RevisionStore in Revision::newFromArchiveRow
Follow up to:
I60568b8ffd22d5e3f861c03b4b8ef14332e9015b

Change-Id: Icab36eecbaa2fdbc8832f2563786c0041930b608
2018-01-02 17:05:24 +00:00
jenkins-bot
7040be4f72 Merge "Revision: Handle all return values of Title::newFromId" 2018-01-01 00:05:25 +00:00
Sam Smith
011b458627 Revision: Handle all return values of Title::newFromId
In Revision::getKnownCurrent, fail early when Title::newFromId returns
null to avoid an uncatchable fatal error being triggered.

RevisionStore#getKnownCurrentRevision requires that the title parameter
be an instance of Title.

This follows on from Ia4c20a91.

Change-Id: I9bddafcc5df630d1dff1e2526194186cab7097e5
2017-12-31 20:44:18 +00:00
addshore
0f6afd3430 [MCR] Revision::newFromArchiveRow remove recently added $title param
The $title param was added as part of
Ieabca1cf157fb667c75fc907b9da2917f71c61b3 and is not yet used
by any code.

The underlying issue with title fetching in RevisionStore has been fixed
in commit 4de36baa63
I15e4663902e2cbfe15b0da2e46449330e313bd0d

This patch removes the param that is not needed, but adds duplicate
logic to fetch a Title object to pass into the Revision object that
is created.
This logic is pulled directly from
RevisionStore::newRevisionFromArchiveRow.

Change-Id: I60568b8ffd22d5e3f861c03b4b8ef14332e9015b
2017-12-28 19:58:20 +00:00
addshore
69f9a18e46 Revert "[MCR] Add and use $title param to RevisionStore getPrevious/Next"
This reverts commit a760526bb4.
This is a PARTIAL revert and the changes to the follwing methods remain:
 - Revision::newFromArchiveRow

This is no longer needed as the underlying issue has been fixed
in commit 4de36baa63
I15e4663902e2cbfe15b0da2e46449330e313bd0d

Change-Id: I3e0ae29e62d59bcb4be871ef5b389a673ce8f103
2017-12-28 18:48:55 +00:00
addshore
8ce1b4dcb5 Revert "[MCR] Add optional $title param to Revision byId methods"
This reverts commit 7bfb4f1951.
and 56b7ba03a2

This is no longer needed as the underlying issue has been fixed
in commit 4de36baa63
I15e4663902e2cbfe15b0da2e46449330e313bd0d

Bug: T183505
Change-Id: I194a558625d15fd4f7929e363557847f8bebde4f
2017-12-28 18:34:17 +00:00
jenkins-bot
07d0b23685 Merge "[MCR] Don't require $title to be passed to Revision::newFromId" 2017-12-24 23:42:56 +00:00
addshore
e51f95dea3 [MCR] Introduce BlobStoreFactory
This allows Revision::getRevisionText to get
a different BlobStore instance when $wiki is passed in
restoring the behaviour for $wiki before the MCR Revision
overhaul patch was merged.
Ia4c20a91e98df0b9b14b138eb4825c55e5200384

Bug: T183634
Bug: T183631
bug: T183583
Change-Id: Ib0949454e9a003c2965adc1aab38e31fcf121afe
2017-12-24 23:22:30 +00:00
addshore
56b7ba03a2 [MCR] Don't require $title to be passed to Revision::newFromId
If the title is not passed in as a param (already known) then select
it in Revision::newFromId instead of waiting for it to be selected
further down the tree.
This means that we can use the same Title object to pass into the
RevisionRecord as well as our legacy Revision object.

The selection chooses either a slave or master depending on
recent writes.

This logic used to be in Revision::getTitle and also in
Revision::newFromConds which was called by newFromId

Bug: T183505
Change-Id: I9cf4ce2c3c86d6bf979a3c88eb423b942b9a1ba4
2017-12-23 10:54:17 +00:00
addshore
e85046bb4a [MCR] Revision::newFromArchiveRow convert overrides for rows
This method used to overwrite attributes, then passed to
Revision::__construct
RevisionStore::newRevisionFromArchiveRow instead overrides row field
names

This patch adds a conversion for the one field that we need to care
about which is 'page' -> 'page_id'.

After looking through the usages in core and extensions it looks
like this will also fix a bug in the following classes which also
passes in 'page'.
 - RevDelArchivedRevisionItem
 - RevDelArchiveItem

Bug: T183564
Change-Id: I6a472b93663a0599abb55453c6939463ff56275d
2017-12-22 16:39:00 +00:00
addshore
a760526bb4 [MCR] Add and use $title param to RevisionStore getPrevious/Next
When the title is already known use it.

This is similar to the issue fixed in
I714ee391caac9bc56ce4c037967e424b44d9c2fe.

As of this patch all methods within RevisionStore
that call getTitle internally also have an option
to pass in an already known Title object.

Bug: T183548
Change-Id: Ieabca1cf157fb667c75fc907b9da2917f71c61b3
2017-12-22 14:40:02 +00:00
addshore
7bfb4f1951 [MCR] Add optional $title param to Revision byId methods
Bug: T183505
Change-Id: I714ee391caac9bc56ce4c037967e424b44d9c2fe
2017-12-22 12:33:23 +00:00
addshore
9ae9c681c5 [MCR] Fix RevisionInsertComplete Revision pass by reference
This was broken in:
6af796f3e0
Ia4c20a91e98df0b9b14b138eb4825c55e5200384
https://gerrit.wikimedia.org/r/#/c/399174/7

Bug: T183503
Change-Id: I674493507ca4aa6677a3bab7a01d6dc3c2cdbc5b
2017-12-21 21:29:44 +00:00