Commit graph

51 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
addshore
142302ea7d Add @see $wgContentHandlerUseDB to RevisionStore params
Change-Id: Ic7c4a7a729b2cac6ac46ae9475167acfe6e8dd9e
2018-06-29 12:55:45 +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
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
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
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
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
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
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
addshore
db8f62e57d RevisionStore logging use wfBacktrace instead of wfDebugBacktrace
wfDebugBacktrace doesn't work very will with logstash.
The whole message ends up being too long and the log ends
up in the 'jsonTruncated' channel.
Instead use wfBacktrace which will be smaller as it just gives
us a string.

Change-Id: I5309ac2ad4592fb6dbb1474526d382893fb7e6c1
2018-02-15 14:15:45 +00:00
addshore
62d16545e2 Fix phpdoc description of RevisionStore::insertRevisionOn
Change-Id: Iae0ac4cf98b1cc93eb5a9f8bb97e64b5ea1d9f0f
2018-02-08 18:09:55 +00:00
addshore
423ba71f42 DI for CommentStore in RevisionStore
Change-Id: I527388514489e79c53b6016a8bd3119ee1750c83
2018-02-08 18:09:41 +00:00
jenkins-bot
bbedc24556 Merge "Pass $key into CommentStore methods and use MediawikiServices" 2018-02-06 15:31:59 +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
c5a751edbf Revert "Remove workaround for comparing database domain IDs."
This seems to have broken stuff, see failing tests on:
https://gerrit.wikimedia.org/r/#/c/406302/

Could not insert main page: RevisionStore for  cannot
be used with a DB connection for jenkins_u0_mw

This reverts commit d2a4d614fc.

Bug: T186017
Change-Id: Ic3de8e856d7d6b224b02816f2c5a1aa0648cd184
2018-01-30 17:55:26 +00:00
daniel
d2a4d614fc Remove workaround for comparing database domain IDs.
Change-Id: I240d68eddec871794ed98b7ce67773114ee73ff7
2018-01-29 19:44:46 -08:00
addshore
9a509a1792 [MCR] RevisionStore::getTitle final logged fallback to master
There have been many issues with RevisionStore and titles due
to code paths that already know the title for a Revision not
passing the title into Revision in various ways or not passing
in the correct queryFlags.
The getTitle method now has a further fallback using Title::newFromID
and Title::GAID_FOR_UPDATE if not already attempted.

Bug: T183548
Bug: T183716
Bug: T183717
Bug: T183550
Bug: T183505
Bug: T184559
Bug: T184595
Change-Id: I6cf13e6baba354b08533a6151bbbc88a317be9d6
2018-01-29 13:44:54 +00:00
Max Semenik
36e6ab15da Fix called function case in a bunch of places
Change-Id: If1e392290a5bab3bce389f7da692e53a748b8aff
2018-01-22 09:10:09 -08:00
daniel
cb94d35c79 Document expandBlob behavior when no flags are given.
Bug: T184749
Change-Id: I5f1f029d928a7bc25877b0eae9f3822ec321b24a
2018-01-14 08:59:42 +00:00
addshore
90ca759f15 RevisionStore, fix loadSlotContent with no $blobFlags
This includes tests that were previously created in:
I6dcfc0497bfce6605fa5517c9f91faf7131f4334

Bug: T184749
Change-Id: Ieb02ac593fc6b42af1692d03d9d578a76417eb54
2018-01-12 14:48:07 +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
addshore
37f52ed762 [MCR] RevisionStore::getTitle, Fix flags passed to Title::newFromID
This was passing $queryFlags directly into Title::newFromID which
expects different flags.

Instead we now set Title::GAID_FOR_UPDATE if $queryFlags will end up
hitting the master.

Change-Id: I9c6e275c22fe74a98e79c54049afa4915a7f565d
2018-01-10 18:26:30 +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
afe3d071a9 [MCR] fix RevisionStore::checkDatabaseWikiId for DB names with dashes.
This is a quick hack, for a proper solution see I6a98684af1d7

Bug: T183914
Change-Id: I45a151a332145438c484e02bbe96cd85dd602b9e
2018-01-04 17:18:41 +00:00
jenkins-bot
8f883450e1 Merge "Revert "[MCR] Add and use $title param to RevisionStore getPrevious/Next"" 2017-12-29 10:28:25 +00:00
jenkins-bot
88dcf22da0 Merge "Revert "[MCR] Add optional $title param to Revision byId methods"" 2017-12-29 10:28:21 +00:00
jenkins-bot
27d86751f0 Merge "Remove duplicate getTitle call in RevisionStore::getNextRevision" 2017-12-29 00:21:56 +00:00
jenkins-bot
95cf21f8ee Merge "[MCR] pass $queryFlags into RevisionStore::getTitle" 2017-12-29 00:20:56 +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
Thiemo Mättig
409da2d8b3 Remove leading backslashes from "use \…" tags
Change-Id: I494b029de089a07e3b946ee78293a12d5036f63e
2017-12-28 16:30:05 +01:00
addshore
b7664a0681 Remove duplicate getTitle call in RevisionStore::getNextRevision
Change-Id: I5b7cd0e2a9ce413e582b4bdeeebc94a143896728
2017-12-28 13:15:49 +00:00
addshore
4de36baa63 [MCR] pass $queryFlags into RevisionStore::getTitle
Bug: T183716
Bug: T183717
Bug: T183505
Change-Id: I15e4663902e2cbfe15b0da2e46449330e313bd0d
2017-12-28 13:14:39 +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