Commit graph

123 commits

Author SHA1 Message Date
Petr Pchelko
4d8dc6b992 Use ActorStore in RevisionStore
Bug: T273290
Change-Id: Iff9b67455d337ea03cb728dd570c4ce760c39e49
2021-02-10 14:37:54 -06: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
Peter Ovchyn
e7e0db5b34 Hard deprecate RevisionStore::newMutableRevisionFromArray
Bug: T272560
Depends-On: I171537c3346a7dd4aeb4fc612d7dd9fba5d64679
Change-Id: If8d079a5d0e9bc9103cf4a6893a9c961d2728534
2021-02-03 22:29:44 +00:00
Petr Pchelko
816e02ae51 Convert RevisionRecord to Authority and PageIdentity
As we convert the RevisionRecord to using Authority,
we no longer need Title instances, so we can convert
that to PageIdentity.

Ideally, we'd part away from using Title at all, but:
1. For foreign wikis PageIdentity has stronger validation,
so calling PageIdentity getId() on Title will break things.
There's still a lot of code depending on lax Title guarantees,
so we keep it.
2. A lot of code still depends on Title, so we try to pass it
through even if we don't nesessarily need to, to save cost
on recreating it later on.

Bug: T271458
Depends-On: I287400b967b467ea18bebbb579e881a785a19158
Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
2021-01-21 13:37:01 -06:00
DannyS712
0637d80572 Hard deprecate the rest of the Revision class
Bug: T246284
Change-Id: I126d7892c90aa2200c668b5717820e729613bed8
2020-07-02 09:02:02 +00:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
DannyS712
a903da26e1 Revision: Hard deprecation constructing with an array or an object
All remaining deployed Revision objects are created with RevisionRecords

Bug: T246284
Change-Id: I08a0a146750d6bf29d127bf2a3d636e46b1ef336
2020-06-23 19:31:18 +00:00
DannyS712
d95f663512 Hard deprecate Revision::getTimestamp
Bug: T254966
Change-Id: I90d42eb4e69d7a9ab5c6e0197fbe6979f589ddb6
2020-06-10 16:57:20 +00:00
DannyS712
f04d825a8b Hard deprecate Revision::getSize
Bug: T254964
Change-Id: I79ff1671921f4d63829338d22126f8c0821bb16c
2020-06-10 05:19:20 +00:00
DannyS712
f8cc519222 Hard deprecate Revision::getPage and ::getComment
Bug: T251853
Bug: T254960
Change-Id: I09fadbebd839a16b46a027f64eaac9a435622321
2020-06-10 04:10:41 +00:00
DannyS712
df7906cd0f Hard deprecate Revision::getContent
Bug: T254703
Change-Id: I50e82d29f87725a2d583a0fc1ebacc467ffee935
2020-06-08 02:44:21 +00:00
DannyS712
1efa543426 Replace core uses and hard deprecate Revision::(de)compressRevisionText
Bug: T246284
Change-Id: I4649a0f30cf8638856f2e66d454b83a397e3e3d4
2020-06-04 01:47:12 +00:00
DannyS712
b4d8adab32 Hard deprecate Revision::getContent(Model|Handler|Format)
Bug: T250981
Change-Id: I5b93e65f7a5b12e910c1e36fc39f60f498edf6c4
2020-06-03 23:52:49 +00:00
DannyS712
94a47c715c Hard deprecate Revision::getPrevious and ::isDeleted
Bug: T251073
Bug: T251593
Depends-On: Iad9b2a1d571033308cd6940101faef0ce468889a
Change-Id: I5d56a51308d8a2983d86231e56d502406323e216
2020-06-03 00:25:37 +00:00
DannyS712
511fd87645 Hard deprecate Revision::getParentId and ::getVisibility
Bug: T250980
Bug: T250714
Change-Id: I8084607090266687395612be26ad2c06f9a60baa
2020-05-27 23:35:18 +00:00
DannyS712
1e36b2c12f Hard deprecate Revision::getUserText, ::isMinor, and ::isCurrent
Bug: T250579
Bug: T250580
Bug: T250608
Change-Id: I89ac77c436245cad3e746b33aec5a42247fda67d
2020-05-26 22:19:54 +00:00
DannyS712
28cb11e8ca Replace uses and hard deprecate Revision::getSha1
Bug: T251233
Change-Id: I815db5120094909b2820b8ca56d65a62f6af82d1
2020-04-30 17:44:11 +00:00
DannyS712
d604eeda36 Hard deprecate Revision::setId
There are a lot of methods names setId, but looking through a codesearch
for deployed code[1], none appear to be for revision objects outside
of the test for the method

Bug: T246284
Change-Id: I32148b3380797352ef0cdf47c05bdd022d88e3ec
2020-04-11 10:22:36 +00:00
DannyS712
9dd9b0cb46 Hard deprecate Revision::setUserIdAndName
Bug: T246284
Change-Id: I97d476bbffac99f8169e13a3f7c1dfca967be8ea
2020-03-30 16:10:53 +00:00
daniel
495323c063 Remove compat code for pre-MCR schema.
NOTE: This was manually tested to ensure it does not
break updates, see T242764.

Bug: T198557
Change-Id: I1d9f5465018bae10124514bc38169e23e0e613e6
2020-03-24 19:45:47 +01:00
Thiemo Kreuz
6b2c9deef5 Replace all new stdClass() with identical (object)[]
This should be the exact same. Its more a style change than anything.
So why do it then?
* I believe this is much less confusing than code mentioning a weird
"standard class". Barely anybody knows what this is, and what the
difference between "object" and "stdClass" is.
* The code is shorter.
* It's even faster. In my micro benchmark it's twice as fast.

Change-Id: I7ee0e8ae6d9264a89b6cd1dd861f0466ae620ccc
2020-03-04 21:18:30 +00:00
DannyS712
2efa4b69a9 Hard deprecate Revision::loadFromTitle
Part of the soft deprecated revision class, no known callers outside
of EditPage, which is updated, and tests, which hide the deprecation

Bug: T246284
Change-Id: I099cb93a12f3a1d9a720e18e3236374321ce7b0c
2020-02-28 19:10:17 -08:00
ArtBaltai
30e54b3962 Introduce ContentHandlerFactory
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers

Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
2020-02-07 00:53:51 +03:00
Max Semenik
dd7026585c Backwards-compatible PHPUnit 8 preparations
This commit splits changes from Ic14f5debc53e55d6714 to reduce it to
only strictly needed things. It can be merged immediately.

Bug: T192167
Change-Id: I8c541a66ea13421dbe7fa51d197d5455cc4786eb
2019-11-02 12:40:07 -07:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Petr Pchelko
06bfc74034 Hard deprecate Revision::getRevisionText() method
Bug: T198343
Depends-On: Ibc943d757b97c144296e7116c1f9caf944c7f345
Depends-On: Ic799aa2dbe26de2e0cbe2be6218341a44ae051e8
Change-Id: I13b737b33b087d92f8ce86a34de6ca0931baa222
2019-10-07 11:31:20 -07:00
Daimona Eaytoy
8545ce131a Kill the remaining usages of PHPUnit4And6Compat methods
Bug: T192167
Change-Id: I1ea19e9b53683b7d32ff9836990ee73ab3e11104
2019-10-06 10:12:54 +00:00
Amir Sarabadani
440297fa3a Clean up most of b/c for phpunit4
We don't support phpunit4 anymore:
https://w.wiki/9UT

Change-Id: Ia7c932998f1a49af1e322ab9e1dc249b7bd2e8b2
2019-10-06 00:14:35 +02:00
Timo Tijhof
01095f8075 Storage: SqlBlobStore no longer needs Lanugage object
Constructing a Language object in order to initialize the
BlobStoreFactory service causes a circular dependency
(see T231866).

SqlBlobStore was using the Language object to all iconv.
But nothing language specific is done in Language::iconv,
so we can just inline the call.

Bug: T231866
Change-Id: I90c25decbcff10ea762a2c7474a12fd2041b3abc
2019-10-02 09:26:34 -07:00
Timo Tijhof
fe3c418925 Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore'
In order to make statistics from WANObjectCache more useful,
each kind of key should generally have a unique first make*Key
component. This usually corresponds 1:1 to a call to make*Key,
unless the same key format is duplicated in muliple places.

In this case, change ('BlobStore', 'address', …, …)
to ('SqlBlobStore-blob', …, …).

Bug: T197849
Change-Id: Iba3ae1bf947d6f56c72df2cf3f2160d458d38c66
2019-09-14 02:22:01 +00:00
Brad Jorsch
c29909e59f Mostly drop old pre-actor user schemas
This removes most of the pre-actor user and user_text columns, and the
$wgActorTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_user and rev_user_text remain in the code, as on Wikimedia wikis the
revision table is too large to alter at this time. A future change will
combine that with the removal of rev_comment, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

ActorMigration's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process. Code using
ActorMigration for accessing the core fields should be updated to use
the new actor fields directly. That will be done for in a followup.

Bug: T188327
Change-Id: Id35544b879af1cd708f3efd303fce8d9a1b9eb02
2019-09-09 11:38:36 -04:00
Aryeh Gregor
7fb4a95563 Remove unneeded overrideMwServices/resetServices
Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
2019-08-29 14:26:18 +03:00
Aaron Schulz
baafb5adb4 Make ExternalStore wrap ExternalStoreFactory and create access class
* Inject settings and global instances as dependencies to the
  ExternalStoreMedium instances. This includes the local wiki
  domain, so that wfWikiId() calls are not scattered around.
* Create ExternalStoreAccess service for read/write logic.
* Deprecate the ExternalStore wrapper methods.
* Add some exception cases for bogus store URLs are used instead
  of just giving PHP warnings and failing later.
* Make moveToExternal.php require the type/protocol to decide
  which ExternalStoreMedium to use instead of assuming "DB".
* Convert logging calls to use LoggerInterface.

Change-Id: I40c3b5534fc8a31116c4c5eb64ee6e4903a6197a
2019-06-28 14:31:44 -07:00
Brad Jorsch
d16d8bdf07 Default $wgActorTableSchemaMigrationStage to SCHEMA_COMPAT_NEW
Probably good to start testing this in CI sometime soon.

This also updates a bunch of tests that were forcing an older stage to
force SCHEMA_COMPAT_NEW instead, or to test both ways (until a future
patch removes the _OLD version).

Bug: T188327
Change-Id: Icb9b55cb9d754f2d30d6883005658b9670834756
2019-05-01 00:48:54 +00:00
Brad Jorsch
0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00
jenkins-bot
bd78869618 Merge "No yoda conditions" 2018-12-09 01:34:23 +00:00
jenkins-bot
023fec5d7b Merge "[MCR] Introduce SlotRoleHandler and SlotRoleRegistry" 2018-12-03 16:20:06 +00:00
daniel
db987c700a [MCR] Introduce SlotRoleHandler and SlotRoleRegistry
These new classes provide a mechanism for defining the
behavior of slots, like the content models it supports.
This acts as an extension point for extensions that need
to define custom slots, like the MediaInfo extension
for the SDC project.

Bug: T194046
Change-Id: Ia20c98eee819293199e541be75b5521f6413bc2f
2018-11-30 12:29:05 -08:00
Brad Jorsch
fd5a1842d2 Default $wgCommentTableSchemaMigrationStage to MIGRATION_NEW
WRITE_NEW mode seems to be working well on Wikimedia sites. Let's change
the default to MIGRATION_NEW so existing installs and Wikimedia CI will
start using the new code rather than the old.

This also fixes some unit tests that were broken with MIGRATION_NEW, and
updates some that were forcing MIGRATION_OLD to force MIGRATION_NEW
instead.

Bug: T166733
Change-Id: I7bf4ad0105dd1f6cc49eba3ddcb7a51badcd5ed3
Depends-On: I30f7cdcc3875f3f7af116c1e41e88f62ab9e91d0
2018-11-28 13:59:19 -05:00
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01: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
Aaron Schulz
fe0af6cad5 rdbms: Database::selectDB() update the domain and handle failure better
LoadBalancer uses Database::getDomainId() for deciding which keys to use
in the foreign connection handle arrays. This method should reflect any
changes made to the DB selection.

If the query fails, then do not change domain field. This is the sort of
approach that LoadBalancer is expects in openForeignConnection(). Also,
throw an exception when selectDB() fails.

The db/schema/prefix fields of Database no longer exist in favor of just
using the newer currentDomain field.

Also:
* Add IDatabase::selectDomain() method and made selectDB() wrap it.
* Extract the DB name from sqlite files if not explicitly provided.
* Fix inconsistent open() return values from Database subclasses.
* Make a relationSchemaQualifier() method to handle the concern of
  omitting schema names in queries. The means that getDomainId() can
  still return the right value, rather than confusingly omitt the schema.
* Make RevisionStore::checkDatabaseWikiId() account for the domain schema.
  Unlike d2a4d614fc, this does not incorrectly assume the storage is
  always for the current wiki domain. Also, LBFactorySingle sets the local
  domain so it is defined even in install.php.
* Make RevisionStoreDbTestBase actually set the LoadBalancer local domain.
* Make RevisionTest::testLoadFromTitle() account for the domain schema.

Bug: T193565
Change-Id: I6e51cd54c6da78830b38906b8c46789c79498ab5
2018-10-10 12:03:30 -07: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
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
452c71663b Consolidate tests for getQueryInfo() and related methods.
This consolidates tests for getQueryInfo, getArchiveQueryInfo,
getSlotQueryInfo, and similar methods that help application logic
be compatible with different migration stages of different aspects
of the revision storage schema.

Bug: T198561
Change-Id: I8e4ae69d7e00721a0af125afaf9a708f7fe99b0a
2018-09-10 18:16:46 +00:00
daniel
53fd8295ff Use consistent caching strategy in Revision storage classes
DEPLOYMENT: This changes the cache key for revision
content blobs. Expect a brief rise in ExternalStore hits.

Bug: T198704
Change-Id: Icc2d16bc5a1e27ba4caea49a784ba7aeac15042a
2018-07-05 17:44:24 +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
0ef66de3cf MCR RevisionStore, multi content mode..
Bug: T174024
Change-Id: Ifabf39e12ba843eb754ad0c029b7d16a311047a5
2018-06-14 17:30:33 +02:00