Commit graph

154 commits

Author SHA1 Message Date
jenkins-bot
1976283835 Merge "Update a lot of unspecific "array" types in PHPDocs" 2020-11-13 21:48:24 +00:00
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Umherirrender
cae4d33248 Use injected ContentHandlerFactory in RevisionStore service
Change-Id: I9e7d6c63c09ddeac561085895dddc90d85a0aec1
2020-10-27 19:57:51 +00:00
Reedy
66de6726b9 Revision: Remove some unnecessary temporary variables for returns
Fixed some indenting as well.

Change-Id: I274c0a0d17ea754238db0161106c5abc87dc37b9
2020-10-03 22:52:01 +00:00
Umherirrender
d790580fda Fix typos related to repeated words
Change-Id: Ibc187d95b003017255bc87adf56afae7a59bd3db
2020-09-27 10:25:36 +00:00
jenkins-bot
2cd59140ec Merge "Add extra details to error log to debug why null revision creation is failing" 2020-09-04 10:14:13 +00:00
daniel
353d985620 Revision: Point to findBadBlobs.php in exception messages
Advertize the fact that production errors resulting from corruption in
the content storage layer can be remedied using findBadBlobs.php.

Change-Id: I4eab773d0d2da57a545f211c2fef36146331c570
2020-08-23 00:50:32 +00:00
jenkins-bot
1f5b2dc105 Merge "Do not call RevisionStore::getSlotsQueryInfo statically" 2020-08-17 22:44:09 +00:00
Umherirrender
b4e53474dc Do not call RevisionStore::getSlotsQueryInfo statically
Change-Id: I4a231e27053db7dbc5b8064e71bf6cf7c517d39f
2020-08-17 23:44:33 +02:00
Ostrzyciel
13dfd35895 RevisionStore: add INCLUDE_* constants
As the same string values are used by multiple methods in
RevisionStore, factoring them out to constants would make sense.

The only other appearances of these strings in core are some
long-deprecated methods that are probably not worth updating.

Change-Id: I85fe6ab96716f237291202dbb1ebefb90bb9f0da
2020-08-17 20:22:17 +02:00
Ammar Abdulhamid
a6284cc69c Add extra details to error log to debug why null revision creation is failing
Bug: T235589
Change-Id: Icae5cdc5b010e23d4956269f64069c0271217af7
2020-08-17 01:14:56 +00:00
Petr Pchelko
b961feca6a RevisionStoreCacheRecord: Fallback to master for update callback.
Bug: T259738
Change-Id: Id76f7c5179fa351a4aba4d5226437ef6338bbdce
2020-08-05 12:27:29 -07:00
jenkins-bot
e633fb9fbd Merge "RevisionStore: add getRevisionIdsBetween method" 2020-08-05 13:38:23 +00:00
Ostrzyciel
38d19b6fbe RevisionStore: add getRevisionIdsBetween method
Motivation:
This method would be useful to many extensions and other parts of
code that want to obtain a list of revisions in a given range. This
is quite hard to do properly, as the limit conditions are rather
complicated, so it would be useful to have a tested, working method
that does this.

This would be especially useful when obtaining a list of reverted
revisions. Currently extensions are provided with the newest and
oldest reverted revision ids, so this method could be used in such
a case. I think at least Echo, FlaggedRevs and EventBus could make
use of it. I also plan to use it in code marking reverted edits with
mw-reverted change tag.

Design:
I've decided for this method to return only ids, as this would suit
many (but not all) use cases and is far simpler than returning entire
revisions. If the method was to return RevisionRecords, it'd have to
have a few extra parameters (which parts of the revision should we
load? which slots should be loaded? should the content be loaded as
well?) and it would quickly grow to a huge supermethod that has way
too many responsibilities and is extremely hard to test reliably.

Bug: T258951
Change-Id: I0b82e8fa8bd7cb8aa599376a72ebc0a3b320c0e9
2020-08-05 12:46:23 +02:00
jenkins-bot
6a542816d2 Merge "RevisionStore: fall back to master if no revision rows were found." 2020-07-27 22:05:13 +00:00
daniel
9bd04f7845 RevisionStore: fall back to master if no revision rows were found.
The fallback was previously done too late, re-trying based on the
same (empty) list of rows from the slots table.

Bug: T212428
Bug: T258666
Change-Id: Ie4aa2be8d73e597e79b7e0c3e12a539acee427a0
2020-07-27 15:26:12 -05:00
daniel
a67cad6d0f Create fallback for undefined content models.
This causes RevisionStore to use FallbackContent instances to represent
content for which no content handler is defined.

This may happen when loading revisions using a model that was defined
by an extension that has since been uninstalled.

Bug: T220594
Bug: T220793
Bug: T228921
Change-Id: I5cc9e61223ab22406091479617b077512aa6ae2d
2020-07-22 19:59:09 +02:00
Bill Pirkle
3e61a42a5f Improve logging for "main slot of revision not found in database"
The "main slot of revision not found in database" issue described
in T212428 has been ongoing for over a year and is throwing an
exception that is difficult to filter out during logstash triage.
Remove the revision id from the exception message, making it easier
to filter out. Instead, include this in new diagnostic logging.

Bug: T256127
Change-Id: I8f986daeab44c0b1c6b6e3fbf126b32053bd58e0
2020-07-01 20:06:30 -05:00
DannyS712
fe201ad436 Don't create Revisions for deprecated hooks if hook is not registered
Once the Revision class is hard deprecated, we will still need to
run hooks that use Revision objects; even though the hooks will be
deprecated, Revision objects still need to be created for them.

To ensure that deprecation warnings aren't triggered by creating
Revision objects in deployed code, for deprecated hooks only
create the Revision object if the hook is registered.

All hooks that pass Revision objects have already been hard deprecated.

Bug: T246284
Change-Id: I7e718551822825cd390662bb201dd13e2e527e8b
2020-07-01 03:44:36 +00:00
Umherirrender
fd1ed0c092 Pass function name to database functions
Useful for logging

Change-Id: Ia2160fb6be5fc93f28ab51f7ae23d7f078247481
2020-06-07 14:16:52 +02:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
jenkins-bot
67d6d6d14a Merge "Revision: Ensure getRevisionByTitle() works for foreign wikis" 2020-05-25 01:59:01 +00:00
Reedy
c50ba9b190 Fix more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I0ccda3d1de29b1044f74ef0972949eb8fbcb707d
2020-05-15 00:32:23 +01:00
Reedy
12a3883a7b Fix SingleSpaceBeforeSingleLineComment
Change-Id: I285af438ce484af40741489797f20455726ec110
2020-05-11 00:57:11 +00:00
Umherirrender
fc8c95e5af Avoid reuse of local variable in RevisionStore
Static code analyzer like phan-taint-check have problems to see the correct escaping in this case

Bug: T216348
Change-Id: I5fb6234ae4007ac7601e6584449e32a305fdb8b5
2020-05-08 21:20:31 +00:00
jenkins-bot
69011218a7 Merge "RevisionStore: improve error handling in newRevisionsFromBatch" 2020-05-08 17:51:45 +00:00
daniel
767aee7bb1 RevisionStore: fall back to master db if main slot is missing.
This is to protect against race conditions. There may be situations
where we already got the revision itself, but information is still
missing from the slots or content tables.

Bug: T212428
Bug: T252156
Change-Id: Id0cd85ae93616ad91b07afeccb766e8345fa7c9c
2020-05-08 12:04:19 +02:00
Máté Szabó
e987ba3a58 Revision: Ensure getRevisionByTitle() works for foreign wikis
Change Ic6f98d8fb changed RevisionStore::getRevisionByTitle to convert
the passed LinkTarget to a Title using Title::newFromLinkTarget, to
address bug T206498.

Unfortunately, this breaks when RevisionStore is operating in the context
of a foreign wiki. In this scenario, when RevisionStoreRecord::__construct
calls Title::getArticleID on the Title instance to perform a sanity check
of the page ID against the page ID reference stored in the revision table
for the given revision record, then Title::getArticleID will lazily fetch
the page ID on the local, rather than the foreign wiki. This results in
an InvalidArgumentException thrown by RevisionStoreRecord::__construct.

This patch changes the logic to only resolve the LinkTarget to a Title
when operating in the context of the local wiki, similar to the checks
that RevisionStore::getTitle and friends are already performing.

It also adds a regression test to verify that
RevisionStore::getRevisionByTitle does not try to access the local wiki
DBLoadBalancer when called in the context of a foreign wiki.

Bug: T248756
Change-Id: I76090fa2907c2db8e23a62959346db531c6d9cb2
2020-05-05 00:58:06 +00:00
daniel
d351bb7e39 RevisionStore: improve error handling in newRevisionsFromBatch
When for some reason we can't determine the title for a revision
in the batch, this should not trigger a fatal TypeError, but handled
gracefully, with helpful information included in the error message.

Bug: T205936
Change-Id: I0c7d2c1fee03d1c9208669a9b5ad66612494a47c
2020-05-03 21:54:02 +02:00
Thiemo Kreuz
d3ca75d18d revision: Fix bad combination of type cast and ?? operator
Introduced a few days ago in If770120.

Change-Id: I1e40c8fcf518aadf4ba526b407dd0e985e6228ce
2020-04-28 16:50:03 +02:00
jenkins-bot
9a939d38d0 Merge "RevisionStore and PageUpdater: handle stale page ID" 2020-04-27 21:16:52 +00:00
daniel
1fcd23878c RevisionStore and PageUpdater: handle stale page ID
Sometimes, an edit is done with a Title object that has gone
out of sync with the database after a page move. In this case,
we should re-load the current page ID from the database,
instead of failing the update hard.

Bug: T246720
Bug: T204793
Bug: T221763
Bug: T225366
Change-Id: If7701205ec2bf4d4495349d3e67cf53d32ee8357
2020-04-20 18:11:45 +02:00
jenkins-bot
260403b83a Merge "Add findBadBlobs script." 2020-04-17 13:32:17 +00:00
daniel
071ce36abd Add findBadBlobs script.
This script scans for content blobs that can't be loaded due to
database corruption, and can change their entry in the content table
to an address starting with "bad:". Such addresses cause the content
to be read as empty, with no log entry. This is useful to avoid
errors and log spam due to known bad revisions.

The script is designed to scan a limited number of revisions from a
given start date. The assumption is that database corruption is
generally caused by an intermedia bug or system failure which will
affect many revisions over a short period of time.

Bug: T205936
Change-Id: I6f513133e90701bee89d63efa618afc3f91c2d2b
2020-04-17 15:04:59 +02:00
Timo Tijhof
1efeda19c7 Revision: use MWTimestamp directly instead of wfTimesamp()
This are fairly straight-forward shortcuts. Use the class directly.

Also remove comments about injecting the current time via callbacks
which is obsoleted by the wikimedia/timestamp now having support for
mocking the time, via Wikimedia\ConvertibleTimestamp::setFakeTime
or (subclass) MWTimestamp::setFakeTime.

Bug: T225730
Change-Id: I5b49f0a0f0ae2daca8f054243b1c4c0a94422653
2020-04-03 15:41:15 +00:00
DannyS712
b2327fef07 Hard deprecate the RevisionInsertComplete hook
Bug: T232877
Change-Id: Ic4b26c86c0f11215a6472a84cc1f44df84d83367
2020-03-31 16:16:42 +00:00
Petr Pchelko
aa1ea49a51 Hard deprecate Revision::loadFromTimestamp
Bug: T246284
Depends-On: Ia8d49b3158baf578ccd3476d6537be36dcea7e13
Change-Id: Ic4df02a7e21d4d1c0140e0f5a985a90f66983fab
2020-03-25 12:21:02 -07:00
Petr Pchelko
b3ab937939 Deprecate Revision::loadFromPageId
Bug: T246284
Depends-On: Id4ec83cc0ac0685857064486697a7daed979ea69
Change-Id: I5de750322e30052700f509d2908456ebd5be95ef
2020-03-25 12:10:48 -07:00
jenkins-bot
bdd722e310 Merge "Remove compat code for pre-MCR schema." 2020-03-25 18:19:33 +00:00
Petr Pchelko
a749000d39 Deprecate Title and WikiPage getFirstRevision methods
They naturally belong in RevisionLookup. They return Revision,
so should be replaced anyway.

Bug: T246284
Change-Id: Ie5c478e4667ca0e773186b9cb8a319cd09145112
2020-03-24 11:56:08 -07: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
Petr Pchelko
bcd30c6952 Move RevisionStore::getRevisionByTimestamp to RevisionLookup
Bug: T246284
Change-Id: I9d5045ce32e12eb783b490f0db4def21d98a6afe
2020-03-18 18:09:56 -07:00
Petr Pchelko
ebd35bdc85 Hard deprecate Revision::getParentLengths
As well hard-deprecate RevisionStore::listRevisionSizes.
It was marked as @deprecated, but the release for the
deprecation was not specified. Let's say it's 1.35.

Additionally, in order to avoid temporary code duplication,
listRevisionSizes now uses getRevisionSizes and ignores the
database object injected into it. This is ok since we're
hard-deprecating the method and all the usages have been
removed.

Bug: T246284
Change-Id: Ifad1c25a0af892b88fce492b2d34c8cf71279b70
2020-03-18 12:26:26 -07: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
77d503db09 Remove Revision::loadFromId(), deprecated and unused
Bug: T242311
Change-Id: I0c8fe834da79cb6db3c2268df50ba460fa97d981
2020-03-01 09:12:30 +00:00
jenkins-bot
409a34e891 Merge "Remove unused variables from closure use() lists" 2020-02-29 17:27:01 +00:00
Umherirrender
a9cae1a917 Remove unused variables from closure use() lists
Change-Id: I11f2e0d7a95caf9d7e8732f8022e6e0685a4223d
2020-02-29 17:10:28 +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
jenkins-bot
7c6ec9a895 Merge "RevisionStore: fail on mismatching hash or size." 2020-02-03 20:25:36 +00:00
Daimona Eaytoy
41ee2f2c61 Upgrade phan to 0.9.1
Released just now.

Many old suppressions can now be removed. Enabling the issue for
undeclared variables is left to do later, given that there are
roughly 200 warning.

Change-Id: I99462a1e9232d6e75022912e2df82bc2038476ef
2020-01-25 10:53:26 +00:00
Daimona Eaytoy
ee51ebf72e RevisionStore: Update docs for renamed method
getRevisionFromTimestamp was renamed to getRevisionByTimestamp
I3b049acff9313814a4ac448289d1aef88cb7f9df, and this comment was left
behind.

Change-Id: I9cf9056768937b3fb6f79ee5cb76fcacf1831f04
2020-01-08 15:55:33 +01:00
daniel
9a7990dea9 RevisionStore: fail on mismatching hash or size.
The SlotRecord passed to RevisionStore::insertRevisionOn may have its sha1 and size
already set by the caller. This is useful when restoring archived re
visions, but apparently sometimes goes wrong, leading to a revision
being recorded with the hash and size of its parent revision.

This patch introduces a sanity check that ensures that the revision's
hash and size matches the main slot's hash and size. If there are
additional slots, the check is skipped.

This does not fix the bug as reported, but should prevent any new
revisions to be inserted with mismatching meta-data, and provide us with
a stack trace that should help with finding the original cause of the
issue.

Bug: T239717
Change-Id: I4947731364925fef1c77cabcfd144fd2c07bf9db
2020-01-06 14:20:16 +01:00
jenkins-bot
cf92c2dc44 Merge "Use namespaced IPUtils class" 2020-01-01 23:56:22 +00:00
Kunal Mehta
99007e96c7 Use namespaced IPUtils class
Change-Id: I047e099a93203a59093946d336a143d899d0271f
2020-01-01 02:36:49 -08:00
Umherirrender
994efc26a5 Expand documentation of RevisionStore::newRevisionFromRow
Change-Id: I970e53c85b999f8eaa299cbd6eaac4dbebc6907a
2019-12-09 16:28:20 +00:00
Brad Jorsch
152376376e Remove hacks for lack of index on rc_this_oldid
In several places, we're including rc_timestamp or other fields in a
query selecting on rc_this_oldid because there was historically no index
on the column.

The needed index was created by I0ccfd26d and deployed by T202167, so
let's remove the hacks.

Bug: T139012
Bug: T239772
Change-Id: Ic99760075bde6603c9f2ab3ee262f5a2878205c7
2019-12-04 16:00:02 -05:00
jenkins-bot
429b8ce473 Merge "RevisionStore: force "Unknown user" instead of empty user name" 2019-12-03 20:55:56 +00:00
jenkins-bot
faea842396 Merge "REST PageHistoryCount: Add object caching with incremental updates." 2019-12-03 04:15:46 +00:00
Umherirrender
2cc97d844a Use array for 'ORDER BY'
It is converted to a valid sql string from the abstract database layer

Also use array for GROUP BY and column alias

Change-Id: I293a563607d115a42c8456c9b9ac66665d71d943
2019-11-29 23:01:07 +01:00
Petr Pchelko
ea04a07b7d REST PageHistoryCount: Add object caching with incremental updates.
Bug: T237430
Change-Id: I7876b7ee9fdf55dbaec5946fb1f28c0ed068de74
2019-11-27 14:56:46 -06:00
daniel
bb43130314 RevisionStore: force "Unknown user" instead of empty user name
When restoring revisions that have an empty user name associated with
them, force "Unknown user" to be used instead, even if the actor table
has an entry for the empty user name.

Bug: T236624
Change-Id: I31edd5f7d89d9b43806ad18e96f5e93cff0f8c6f
2019-11-26 22:16:56 +01:00
Petr Pchelko
7fef88e7cc REST: Implement from and to for editors count handler.
* Move Title::{get,count}AuthorsBetween to RevisionStore
* Use it in REST count handler to to provide 'from' and 'to'
support for editors count.

Bug: T235896
Bug: T235666
Change-Id: Ib7947ae64b82871ceb4a3097a0ea03c0ba218c7c
2019-11-05 07:48:38 -08:00
Petr Pchelko
d951e6ccb6 REST: Add 'from' and 'to' parameters to historycount endpoint.
* Add 'from' and 'to' query parameters to history count endpoint,
in case we are counting 'edits'. The support for parameters will be
expanded in the future, given that 'editors' is on the way.

* Refactor RevisionStore::countRevisionsBetween to be able to omit
starting or ending revision.

Bug: T235666
Change-Id: I1fc3f2d4e422f17ccfc99664ea35e210c13ade5f
2019-11-04 15:21:22 -08:00
Petr Pchelko
6eb67c752e Move countRevisionsBetween from Title to RevisionStore
Bug: T235666
Change-Id: Ib404d29a662de7736b50a1d07380f651d332ad6b
2019-10-17 08:02:26 -07:00
Daniel Kinzler
3ebbf29498 Log a warning when the 'text' flag is used with getQueryInfo()
In SCHEMA_COMPAT_READ_NEW mode, the 'text' flag should no longer be
supported by RevisionStore::getQueryInfo().

This reverts commit f7ca65da88.

Change-Id: I8b4dfc783724395586836c7565fd2d66dd653e80
Depends-On: Ibc943d757b97c144296e7116c1f9caf944c7f345
Depends-On: Ic799aa2dbe26de2e0cbe2be6218341a44ae051e8
Bug: T200918
2019-10-07 19:14:01 +00:00
Petr Pchelko
2709495dea RevisionStore::newRevisionFromBatch should use Title::newFromRow
If the rows were obtained using RevisionStore::getQueryInfo with
'page' flags, the revision row already contains the fields needed
to construct the Title without an additional database query.

Change-Id: Ie36c85871a8996a5706c80d286854a9c8363905f
2019-09-30 11:50:42 -07:00
daniel
b1867ec1da RevisionStore: Introduce getContentBlobsForBatch
getContentBlobsForBatch provides a more low level interface than
newRevisionsFromBatch, allowing bulk access to serialized content
without the need to instantiate Title, RevisionRecord, RevisionSlots,
SlotRecord, and Content objects.

Bug: T228675
Bug: T234034
Change-Id: I8481ad211e2d9f11bc10ea10c16e78b74538d95b
2019-09-27 11:15:06 -07:00
Clara Andrew-Wani
320ec708e4 Force usage of MCR aware database schema
Bug: T214308
Change-Id: I2ae4e82a12f730617563eb6f911fc406b9195391
2019-09-27 11:31:23 +00:00
daniel
5b34a67f12 newRevisionsFromBatch: don't throw on duplicate row.
Bug: T228988
Change-Id: I907fe25692a74b591300b2f182ac6234c22c8071
2019-09-24 21:08:33 +02:00
daniel
ffde7b8cb4 Improve documentation of newRevisionsFromBatch()
Document purpose and behavior of the $title parameter.

Bug: T228988
Change-Id: I89966321ec3b4feb5a59e06b8a656d76c4bd9ef2
2019-09-24 19:19:50 +02:00
Petr Pchelko
d5a5cf502d Use BlobStore::getBlobBatch for RevisionStore::newRevisionsFromBatch
Bug: T233173
Change-Id: I3ffcfabc3524ce137593e0dba32c83f5eb7e5763
2019-09-19 10:19:11 -07:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
Petr Pchelko
f9cc7e0416 Introduce RevisionStore::newRevisionsFromBatch
Bug: T228988
Change-Id: Ia82e47e44dd70def6d6d5d4f598f9ae969645aae
2019-09-03 12:23:01 -07:00
Daimona Eaytoy
327e8ea416 Unsuppress phan issues part 6
Bug: T231636
Depends-On: I50377746f01749b058c39fd8229f9d566224cc43
Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
2019-09-01 09:48:45 +00:00
Aaron Schulz
4dfeb4b4b9 revisionstore: clean up redundant DB connection code in RevisionStore
Change-Id: If9c2391046936862bee05cfbd8cdc9440347071c
2019-08-04 10:50:50 -04:00
Aaron Schulz
83e294a892 Convert LoadBalancer::getConnection() callers to LoadBalancer::getConnectionRef()
Change-Id: Ie1ae322202105ce093779e6d0b00f335c71be31f
2019-07-21 01:02:49 -07:00
Aaron Schulz
837f2d76ae storage: remove wfWikiId() call from RevisionStore::checkDatabaseDomain()
This should only already be comparing DB domains

Change-Id: If2d40fe1ce4698d71d8a29f8a43b40a8fbb746e8
2019-07-13 17:36:23 +00:00
Umherirrender
f4a3ff1b76 Fix types around ILoadBalancer and IResultWrapper
Change-Id: I08531ccc6db046114f3535cfe6c108936dfff0d0
2019-07-04 21:56:31 +02: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
Aaron Schulz
ca00e47f53 revision: rename various $wikiId fields/parameters to $dbDomain
These fields are passed to methods like LoadBalancer::getConnection() and are
already expected to be DB domains. Update various comments as well.

Fix a few minor IDEA warnings.

Change-Id: I7cf76700690aec449872a80d30b5ba540d2bf315
2019-06-28 21:30:25 +00:00
daniel
dd14601afb Join slot and content tables when dumping XML
This introduces a way to construct a RevisionRecord based on a
known set of SlotRecords. To allow this to be used consistently
with the legacy revision schema, some tweaks had to be made
to getSlotsQueryInfo().

Bug: T220493
Change-Id: I5ea972bb07ca1cfb3a2ad8ef120aef77e460745c
2019-06-27 22:26:22 +02:00
Aaron Schulz
69c503148f rdbms: add replica server counting methods to ILoadBalancer
This is slightly more robust and makes the intent much clearer
than random calling code checking getServerCount() all over the
place. In addition, this yields better separation of concern.

Also, cleanup the LoadBalancer constructer a bit and make the
validation a bit stricter.

Make some server index comparisons strict while at it.

Change-Id: Icc1a35bd65c6862ff81faa3ab9b2aa7cafe29443
2019-06-20 12:47:23 +01:00
Derick Alangi
2dca5bbbf5 Remove unnecessary semi-colons
Change-Id: I9eb65bdfbd3aa581effc14ead801b9e89b0359c3
2019-06-12 14:35:59 +01:00
James D. Forrester
460bcf81e7 build: Upgrade mediawiki/mediawiki-phan-config from 0.5.0 to 0.6.0 and make pass
Fix five instances of PhanPluginDuplicateConditionalNullCoalescing;
escape the rest for now.

Bug: T219114
Change-Id: Ic4bb30c43c5315ce6b878b37b432c6e219414f8b
2019-05-13 14:57:07 +00:00
jenkins-bot
8d9d8c8bb3 Merge "Force user id and actor id to 0 when loading from remote wikis" 2019-05-06 15:19:38 +00:00
Bill Pirkle
d4b72572a6 Force user id and actor id to 0 when loading from remote wikis
Stop-gap solution for the problem described in T222212.
Force the User ID and Actor ID to zero for users loaded
from the database of another wiki, to prevent subtle data
corruption and confusing failure modes.

Bug: T222381
Change-Id: Ic585f972d61da136744d080df13d8eb1ecd04cf5
2019-05-06 09:08:51 -05:00
Aryeh Gregor
090f6daa1b Move getPrevious/NextRevision logic out of Title
They belong in RevisionStore. This change removes the dependency on
Title for these methods and will assist in porting more code to
LinkTarget.

At the same time, deprecate the Title parameter to
RevisionLookup/RevisionStore getPreviousRevision/getNextRevision, and
add a $flags parameter to match the functionality of the Title versions.
Since code search turned up no callers that passed a Title outside core,
this variant is immediately hard-deprecated. The Title methods
themselves are only soft-deprecated.

Change-Id: I76bc6fd6ee1a9f35b5f29fa640824fb5da3bb78e
2019-05-05 21:08:46 +03:00
Aryeh Gregor
908e46028a Don't require Title for getTimestampFromId
3e36ba655e added an option for passing a page ID to this method of
Revision, and e03787afd9 switched it to a Title and made it mandatory.
This behavior propagated to the method in RevisionStore.  As far as I
can tell, the parameter does not help anything, but it can add a
database query to get the page ID if it's not cached, and impedes
conversion to LinkTarget. I can't figure out any reason to not
completely drop it. I've noted it as deprecated but still supported it
for now for compatibility -- I found one extension that does pass it.
(It's ignored, though, which theoretically would be a behavior change if
someone was passing a Title that didn't match the revision ID.)

While I was at it, I added the method to RevisionLookup, although it's
only used in later patches. Properly I should move that piece to a later
patch, but it didn't seem worth the effort.

I didn't change the Revision method, because the whole Revision class is
deprecated anyway.

Change-Id: I26ef5f2bf828f0f450633b7237d26d888e2c8773
2019-05-05 14:35:53 +03:00
jenkins-bot
a44ae41d58 Merge "Fix/suppress misc phan errors (#4)" 2019-04-05 22:42:35 +00:00
Kunal Mehta
e844daa4f3 Fix/suppress misc phan errors (#4)
* RevisionStore: phan is confused by the array not being the callable
* ApiContinuationManger: phan false positive
* ChronologyProtector: fix doc block
* MssqlBlob: phan doesn't like __construct returning things
* WikiPage: Remove Revision typehint that doesn't match doc block

Change-Id: I0661d97424d0ad6f7a3357542e79aceb6a4f6c64
2019-04-05 22:28:31 +00:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Jason Linehan
aed6be47ac Fully utilize LinkTarget passed to getRevisionByTitle
Failure of getRevisionByTitle to pass its LinkTarget argument
to newRevisionFromRow resulted in a needless second instantiation
of the Title (an extra query).

Because newRevisionFromRow needs a Title, not just a LinkTarget,
it is unfortunately necessary to call Title::newFromLinkTarget
on it for now -- however this does not involve a DB lookup and
is on track to be fixed with revisions to the Title class.

Bug: T206498
Change-Id: Ic6f98d8fbf66d85121668571c17e148efc5ec2be
2019-04-02 21:25:45 +00:00
Max Semenik
4004d3d868 Fix function/class case
Change-Id: I18c205736be9d76d2c09a6dc4d7377740a742ccc
2019-03-29 16:20:50 -07:00
jenkins-bot
1e1c24d12c Merge "Avoid using stale data for revision visibility and actor data" 2019-03-11 14:37:48 +00:00
Bill Pirkle
276bf4a76b Avoid using stale data for revision visibility and actor data
Created class RevisionStoreCacheRecord to avoid returning stale
cached revision visibility and actor data when changes were
made after the cache was populated for that revision.

Bug: T216159
Change-Id: Iabed80e06a08ff0793dfe64db881cbcd535cb13f
2019-03-10 15:34:44 -05:00
Aaron Schulz
cb15755e92 Normalize use of "INNER JOIN" to "JOIN" in database queries
The ANSI SQL default join type is INNER and this might save
some line breaks here and there.

Change-Id: Ibd39976f46ca3f9b71190d3b60b76ca085787a00
2019-03-06 09:17:30 -08:00
jenkins-bot
b9333ae655 Merge "RevisionStore: Avoid exception on prev/next of deleted revision" 2018-12-03 21:07:44 +00:00
jenkins-bot
023fec5d7b Merge "[MCR] Introduce SlotRoleHandler and SlotRoleRegistry" 2018-12-03 16:20:06 +00:00
Jakub Vrana
f11471e8e0 Remove unused use in anonymous function
Found by PHPStan.

Change-Id: Id2dd9996fd4d78da930ee0cc802bb07b66a5f084
2018-12-01 10:13:38 +01:00