Commit graph

112 commits

Author SHA1 Message Date
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
daniel
257f877904 Ignore order of slot roles in test assertions
Bug: T197271
Change-Id: I1448c3907157d4d79f69f5344e6069b4f8be43bc
2018-06-15 10:01:04 +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
f6c225e456 Tests for preserving content ID and origin during undeletion
Bug: T194015
Change-Id: I6d9a1390c7080d910d43097afb703d13cd500c1b
2018-06-14 13:51:01 +00: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
daniel
e4b775acf1 Suppress addCoreDBData() in tests overriding the revision schema.
Some unit tests for the MCR schema migration change the DB schema
in the test setup. However, addCoreDBData() will not work with the
modified schema. Since these tests don't actually need addCoreDBData()
to do anything, they can simply override it to do nothing.

Without this change, tests for Ic2221da30c and Ifabf39e12ba843
fail with $wgMultiContentRevisionSchemaMigrationStage = MIGRATION_WRITE_BOTH.

Change-Id: I86e140ec981dfa4e904822b1600399c533f9e3d6
2018-06-14 07:41:28 +00:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
daniel
32e9266d8d Introduce per-schema unit tests for revision storage.
This introduces traits for testing different schema variations.
These are not very useful in this patch, but make it much easier
to add tests for MCR schema migration in subsequent patches.

The code in this patch was previously part of If259b1e1c49ceaa4.

Change-Id: I239572f75bebbc9c731a3e3860c4eff179dc15e4
2018-06-07 13:31:16 +00: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
e1a203603c Replace wfGetLB
@deprecated since 1.27

Change-Id: Ibdd49fdfc0d1511503e1ed2173a592c612996c53
2018-05-02 22:30:24 +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
Aaron Schulz
3b58b6d143 Fix testGetMap_twoValues() failures for sqlite
Change-Id: I3f42208d8e42ba923d4b08bb7efe15f871165899
2018-04-13 14:16:39 -07:00
Brad Jorsch
8dfeac7446 rdbms: Add a deprecationLogger callback
Much like the existing errorLogger, but for logging deprecation
warnings.

The default in the RDBMS layer is to call trigger_error() with
E_USER_DEPRECATED. The default in MediaWiki (via MWLBFactory) is to log
to the 'deprecated' log group, much like wfDeprecated() does, although
unfortunately we can't effectively use that directly since we have no
idea of a proper $callerOffset to pass.

Change-Id: Id13625e249516e84d72b6310953bb338a90976da
2018-04-05 22:25:08 +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
0b2b8e94cd Merge "tests: Remove some unused stuff in phpunit tests" 2018-03-26 22:59:06 +00:00
Max Semenik
aa9bbe6051 tests: Remove some unused stuff in phpunit tests
Change-Id: Ica20e4f4ac0887b7cac12700ffcd15f587b3ba01
2018-03-26 22:45:29 +00:00
daniel
b0bdfd7e9f MCR: replace slot_inherited with slot_origin
Bug: T189004
Change-Id: Ie9dbda3296a71f584c82a5f275098adc225a53d5
2018-03-19 21:51:56 +01: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
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
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
jenkins-bot
92571d7c1a Merge "[MCR] RevisionStore::getTitle final logged fallback to master" 2018-02-06 11:42:52 +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
1c65dd29a3 Add tablesUsed to RevisionStoreDbTest
Bug: T183777
Change-Id: Ie8bc2a9aca341a44c22828c9e9c3a7f89c7f87cd
2018-02-02 19:37:44 +00: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
addshore
4b928c87dc Extra tests for SqlBlobStore with 'windows-1252' legacy encoding
Bug: T184749
Change-Id: Ida717dbe6ae742b3b61f0f09dc60712307c53a96
2018-01-24 22:08:46 +00:00
Aaron Schulz
14ee3f2107 rdbms: specify DB name and table prefix even for the local domain
When LoadBalancer opens new local domain connections, it currently
assumes that the domain specified by the server info array is the
same. For sanity, make sure that the handle is set to the local
domain.

The main LBFactory/LoadBalancer use $wgDBname/$wgDBprefix as the
local domain, corresponding with wfWikiId(). This relation is set
automatically in MWLBFactory. If $wgLBFactoryConf/$wgDBservers is
manually configured in a way breaking this correspondance, then it
is misconfigured.

Fixes made to avoid test failure:
* Make sure LoadBalancer::setDomainPrefix() updates the local
  domain alias member. Also do not bother changing the domain of
  foreign connections.
* Use the right domain ID for the connection array key names in
  LoadBalancer::openForeignConnection().
* Now that JobQueueTest no longer mistakenly uses the non-test
  tables, force it to use the main DB_MASTER handle so that it can
  see the unit test tables even if they are TEMPORARY; such tables
  are tied to the TCP connection, so separate handles see different
  temporary tables.

Change-Id: I56f8b32fe957f984b8c9753e6db3b20abe96b038
2018-01-16 17:06:52 +00:00
daniel
0205d43803 Add tests for legacy encoding when constructing RevisionRecords
Change-Id: I49265a394b0780a48fecbf037477d2bb39195e89
2018-01-12 14:59:52 +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
addshore
47cbdfa7fa RevisionStore tests for current behaviour of getTitle
Change-Id: I6e345b10abb81f6eae94ab9475563f690aaee012
2018-01-11 17:09:36 +00:00
jenkins-bot
d1a1d04fc8 Merge "Fix BlobStoreFactoryTest @covers tag" 2018-01-08 13:29:03 +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
addshore
4f472847bc Fix BlobStoreFactoryTest @covers tag
Change-Id: I6d61d128de3fc63d88c7767f90350f3edbfc447c
2018-01-08 12:03:35 +00: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
Reedy
2c1c823870 Append leading \ to BlobStoreFactoryTest covers
Change-Id: I9b85aa9808c40aa728c6ef186c50bc8cdda08bc6
2017-12-30 05:02:03 +00:00
Kunal Mehta
54640d4d4e Add @covers tags for RevisionStoreDbTest
Change-Id: Ie7ce23d5ad67816c1ae8c2c838f8263fca17b4f8
2017-12-27 17:43:50 +00:00
jenkins-bot
073fd06f15 Merge "[MCR] Introduce BlobStoreFactory" 2017-12-24 23:39:58 +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
jenkins-bot
51615ecf47 Merge "Set wgCommentTableSchemaMigrationStage in RevisionStoreTest" 2017-12-23 12:08:42 +00:00
addshore
d4717253b2 Remove empty RevisionRecordTest
Bug: T183219
Change-Id: Ic58308da4a54186995a2d985b40e0bbf86b8cef3
2017-12-19 17:50:03 +00:00
jenkins-bot
86719704b8 Merge "SqlBlobStoreTest: Use utf-8 as name in iconv" 2017-12-15 22:04:24 +00:00
Umherirrender
78dd15c08d Set wgCommentTableSchemaMigrationStage in RevisionStoreTest
Change-Id: I2d8bfdee0a30a54f4315c8056b7ac84f47254db2
2017-12-15 21:44:27 +01:00
Umherirrender
84b9564e50 SqlBlobStoreTest: Use utf-8 as name in iconv
utf8 is an alias that doesn't work with all PHP installations.

Change-Id: I6ce9c5b4ece1a8c263afb1d4895dacd3c790a51a
2017-12-15 19:56:48 +01:00
mainframe98
70e92cdad5 Fix additional usage of incorrect case
Courtesy of the PhpStorm inspection Case mismatch in method call or
class usage.

Bug: T166759
Change-Id: I27c53658b99048fa0dd8f9d6ef1398620386e1cc
2017-12-15 11:58:11 +01:00
Kunal Mehta
471ec51c93 Fix @covers tags to use absolute class names in Storage tests
PHPUnit doesn't support use statements when evaluating @covers tags.

Change-Id: I7f649afd3e417a6b71b2f61c6ff59be5f404be8f
2017-12-14 19:20:51 -08:00
addshore
06127159e8 [MCR] Tests for RevisionStore & Related classes
Code introduced in:
I140f43a6fb443b38483f41f268c906b9cea64cf7

Change-Id: Iefad870baf2d16f12e9901b303246c64d6431ca6
2017-12-14 13:44:55 +00:00
daniel
e61a1caadd [MCR] Break Revision into RevisionRecord and RevisionStore
Bug: T174025
Change-Id: I140f43a6fb443b38483f41f268c906b9cea64cf7
2017-12-13 22:34:29 +00:00