Commit graph

87 commits

Author SHA1 Message Date
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Aaron Schulz
c121d44fd0 Use CONN_TRX_AUTOCOMMIT instead of deprecated CONN_TRX_AUTO alias
Change-Id: I23dc7052bd1ca9a9c8fec2409f3067304745043a
2018-07-03 13:03:44 +01:00
jenkins-bot
94c6443ee9 Merge "Consolidate AtomicSectionUpdate code in DerivedPageDataUpdater." 2018-06-29 17:19:01 +00:00
addshore
142302ea7d Add @see $wgContentHandlerUseDB to RevisionStore params
Change-Id: Ic7c4a7a729b2cac6ac46ae9475167acfe6e8dd9e
2018-06-29 12:55:45 +00:00
addshore
eb39d5f945 Introduce RevisionStoreFactory & Tests
Bug: T194729
Change-Id: I0a8a441b803816281113e52a2a57cc07af8a1119
2018-06-29 12:55:20 +00:00
daniel
7502db65ef Consolidate AtomicSectionUpdate code in DerivedPageDataUpdater.
Change-Id: I7f60f275b7c80590c4c85517fec57474e3e23442
2018-06-27 10:47:10 +00:00
jenkins-bot
712396e716 Merge "Make undo fail if more than just the main slot is affected." 2018-06-23 08:59:37 +00:00
jenkins-bot
75106ac214 Merge "MCR: rename $baseRevId paramter to match actual semantics." 2018-06-22 14:42:07 +00:00
daniel
ef1edcea3c Make undo fail if more than just the main slot is affected.
Bug: T194412
Change-Id: Ifdf9bc9d884844f9ffeb8019d9b13d5737862063
2018-06-22 15:18:41 +02:00
daniel
731a113aac MCR: rename $baseRevId paramter to match actual semantics.
The $baseRevId in WikiPage::doEditContent is used only to indicate what
revision an edit reverted to. It is not used to indicate the actual base
revision of an edit in any sense. Specifically, EditPage never sets it.

So, this change renames the parameter to $originalRevId to match $undidRevId.
It also renames PageUpdater::setBaseRevisionId to setOriginalRevisionId.
Further, this introduces a paramter to PageUpdater::hasEditConflict():

Before this change, PageUpdater::hasEditConflict() was based on the
revision set via PageUpdater::setBaseRevisionId(), assuming the semantics
of "base revision" used by EditPage. However, this is NOT how the $baseRevId
parameter in WikiPage works.

Bug: T197685
Change-Id: Ib78257d4d6ee7c4ec093d5706904c599b02c73e0
2018-06-22 11:57:59 +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
addshore
f84d47160c Move getFieldsToStore to own method in NameTableStore
In the future this opens up an easy posibility of subclassing
if this is made protected.

Change-Id: I640c9f12f52dbb3328523402d9223ee8c967adda
2018-06-15 07:28:37 +00:00
jenkins-bot
1abf584017 Merge "Introduce argument for insert callback in NameTableStore" 2018-06-14 16:06:00 +00:00
Amir Sarabadani
20c9b6eb59 Introduce argument for insert callback in NameTableStore
This will be useful in cases we need to define more data
when inserting a new row

Bug: T193868
Change-Id: Ib5c2da2ef951e0bc782847ff8bd4606681ee2196
2018-06-14 15:51:16 +00:00
addshore
0ef66de3cf MCR RevisionStore, multi content mode..
Bug: T174024
Change-Id: Ifabf39e12ba843eb754ad0c029b7d16a311047a5
2018-06-14 17:30:33 +02:00
daniel
0a4d29c218 Prepare newNullRevision for MCR.
Bug: T174024
Change-Id: I8c607ed666295a5072c4fbfad1cf91d74d743abb
2018-06-14 17:03:14 +02:00
addshore
125bf7e44f [MCR] RevisionStore, enable insertions for new schema
Enable inserts to the new MCR db schema in single slot mode only.

TODO:
 - RELEASE NOTES

Notes:
 - When in MIGRATION_WRITE_NEW or greater, deleting and then
 restoring a page will result in different data in the revision table.
 For example, if you delete a page that has text_ids present in the
 revision table and restore it, the text_ids will be blank after.
 - When in MIGRATION_WRITE_BOTH or greater the archive table will
 start to ar_content_model entries where previously it would have been
 given NULL. This is due to the old content schema having NULL in the db
 when the default content model is used, but the new schema will always
 have a value, taken from the content_models table

Note: If259b1e1c49ce was squashed into this change.

Bug: T183488
Bug: T174024
Change-Id: Ic2221da30c8f6ac2ba42720fcd568f2d0ed70534
2018-06-14 13:36:08 +00:00
daniel
e8632ab0f6 [MCR] Factor PageUpdater out of WikiPage
This introduces PageUpdater to replace WikiPage::doEditContent,
and DerivedPageDataUpdater, to replace WikiPage::doEditUpdates
and WikiPage::prepareContentForEdit.

See docs/pageupdater.txt for a description of their
functionality.

MCR migration notes:

* The interface of PageUpdater is expected to
remain mostly stable after this patch. Code that has been using
WikiPage::doEditContent can be confidently migrated to using the
new mechanism for revision creation.

* This patch keeps the code inside PageUpdater largely aligned
with the old code in WikiPage, to make review easier to to avoid
mistakes. It is intended to be refactored further, moving
application logic into stateless services.

* DerivedPageDataUpdate is intended as a stepping stone for further
refactoring. Its behavior is designed to be compatible with
callback code that currently relies on
WikiPage::prepareContentForEdit. Much of the code that currently
lives in DerivedPageDataUpdate should be factored out into
services, all behavior relevant to calling code should be exposed
via narrow interfaces.

Bug: T174038
Bug: T196653
Change-Id: If610c68f4912e89af616cdcac1d35a1be3946afa
2018-06-14 13:22:13 +00: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
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -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
Bartosz Dziewoński
52b0799e8d Use PHP 5.6 constant expressions for some bitfield constants
I searched the entire codebase for 'const' and looked for things
that looked suspiciously like manually calculated bitfield unions.
As of PHP 5.6, we can have them calculated automatically when
defining constants.

Change-Id: I7d971d1a63f8916db2f8f6c053c7dd0a13add92d
2018-05-30 18:05:18 -07:00
jenkins-bot
486895a5b3 Merge "[MCR] Introduce RevisionSlotsUpdate." 2018-05-09 13:27:08 +00:00
daniel
8b0506bd8b
[MCR] Introduce RevisionSlotsUpdate.
The RevisionSlotsUpdate interface represents a change to a pages slots,
as applied by an edit.

This also introduces RevisionSlots::hasSameContent and pulls up
getTouchedSlots() and getInheritedSlots() from MutableRevisionStore
to RevisionStore, in preparation of using these classes in the
refactoring of WikiPage::doEditContent and friends.

Bug: T174038
Change-Id: Idb0ef885b343a76137b640fdfc1bf36104b00895
2018-05-08 15:58:51 +02:00
Umherirrender
7eb7f04771 Change @throw to @throws
Phpcs does not look at private functions

Change-Id: I9adedf1f1c488e74db7de89e97cb6a481bf7d567
2018-04-27 21:53:19 +02:00
jenkins-bot
2224e31507 Merge "Drop archive.ar_text and ar_flags" 2018-04-23 20:15:26 +00:00
jenkins-bot
3d77e43e9b Merge "Fix handling of ar_length and ar_sha1 in RevisionArchiveRecord." 2018-04-19 18:41:13 +00:00
jenkins-bot
7f87ffa3b5 Merge "Introduce SqlBlobStore::makeAddressFromTextId" 2018-04-19 17:53:45 +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
daniel
040d5b2552 Fix handling of ar_length and ar_sha1 in RevisionArchiveRecord.
This makes sure that length and hash are calculated if not known.

This patch also adds missing unit tests for RevisionArchiveRecord,
and consolidates unit tests for the different RevisionRecord
subclasses using a trait.

Bug: T192189
Change-Id: I5e1d17ba96e61e068b6aa5ac9c45ac0f657905a6
2018-04-18 21:47:57 +02:00
jenkins-bot
fac86a2fcf Merge "Use constants for rc_patrolled values instead of numbers" 2018-04-14 02:39:33 +00:00
Amir Sarabadani
6a2cd1c5c2 Use constants for rc_patrolled values instead of numbers
These are recently introduced, better to use them

Change-Id: Id904ff09081cb5a1fe2f1c24c5d415da18fd2294
2018-04-13 23:56:35 +02:00
Aaron Schulz
3b58b6d143 Fix testGetMap_twoValues() failures for sqlite
Change-Id: I3f42208d8e42ba923d4b08bb7efe15f871165899
2018-04-13 14:16:39 -07:00
Aaron Schulz
f8c2486d15 rdbms: rename CONN_TRX_AUTO constant to CONN_TRX_AUTOCOMMIT
The "AUTO" means AUTOCOMMIT, not "automatic transactions"/DBO_TRX,
which is basically the opposite concept. The new name does not
suffer from that ambiguity.

Keep the old constant as an alias for backwards compatibility.

Also remove LoadBalancer comment about non-existing field

Change-Id: I63beeb061fc9be73f320308e4d6393b58628b8c8
2018-04-12 13:01:52 -07: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
9ced9ebca2 Merge "MCR: replace slot_inherited with slot_origin" 2018-03-20 12:06:32 +00:00
daniel
b0bdfd7e9f MCR: replace slot_inherited with slot_origin
Bug: T189004
Change-Id: Ie9dbda3296a71f584c82a5f275098adc225a53d5
2018-03-19 21:51:56 +01:00
Brad Jorsch
ff35ae6195 RevisionStore: Properly encode timestamp
Timestamps in database queries need to be passed through
IDatabase::timestamp().

Change-Id: I1c163d80b2111a78bb10de49fe06d61f02c21d07
2018-03-17 21:41:45 -04:00
daniel
ec108ea14b Fix field names and behavior in SlotRecord.
The field names used in SlotRecord got out of sync with the changes made
to the database schema. Nobody noticed, because these fields are not yet
written to or read from the database.

This change also rewrites SlotRecordTest and adds several sanity checks
to SlotRecord, in preparation of the introduction of slot_origin.

Change-Id: Ifdf040174705bf88104b8c922c9d6d1120d48f3a
2018-03-08 12:53:25 +01:00
Roan Kattouw
a1e58d2455 Fix master/replica race condition when creating null revisions
RevisionStore::newFromNullRevision() carefully reads the latest revision
from the master, but then forgets to instruct emulateMainSlot_1_29() to
do the same, so the lookup query for rev_text_id in the text table is
done against a replica.

This is not usually a problem for null revisions, but it is a problem
when editing a page and then immediately moving it: this causes a null
revision to be created based on a freshly created revision, which
doesn't yet exist on the replica.

Bug: T184670
Change-Id: Ied4db5ee770716ff3edb918d2be722934c79d0c7
2018-03-02 19:54:45 -08:00
jenkins-bot
e72c8c8aa7 Merge "Introduce hasSlot in RevisionRecord and RevisionSlots." 2018-03-02 20:38:59 +00:00
addshore
4d3549ad71 [MCR] NameTableStore
General purpose cached store for things like:
 - content_models (id,name)
 - slot_roles (id,name)
And in the future possibly namespaces & content_formats
as mentioned at:
https://www.mediawiki.org/wiki/Multi-Content_Revisions/Schema_Migration#Name_tables

Bug: T188518
Change-Id: Ia550ef7fe30af25ac3fee5ac8a89d032544563bf
2018-03-02 19:48:15 +00:00
daniel
8e85cd44bc Introduce hasSlot in RevisionRecord and RevisionSlots.
Change-Id: Ie7ee2afe26d37ac726f4682c96166cb89134227c
2018-02-26 17:34:48 +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
Aaron Schulz
d9ba7cd005 Make LocalFile check early if the revision store is available
This reduces the odds of having files without corresponding
wiki pages, given that the later is done in a deferred update.

Also made some documentation cleanups.

Bug: T187942
Change-Id: Iff516669f535713d37e0011e2d7ed285c667f1c5
2018-02-22 22:07:30 +00:00
Brad Jorsch
a7c103f24d RevisionStore: Remove reference to unimplemented 'ar' blob address schema
It was thought that an 'ar:' schema for SqlBlobStore addresses would be
needed to support archive rows from before MediaWiki 1.5 that still
stored the text in ar_text and ar_flags instead of using the text table
and ar_text_id. But this schema was never actually implemented.

Now I5608c6b6 has migrated that content to the text table and
ar_text_id, and I18f1c740b will remove the database fields entirely. So
there's no reason to ever implement this schema.

Change-Id: Ic449478c244bb13a8c5139e20488e876c0a793bb
2018-02-22 10:44:21 -05:00