Commit graph

94 commits

Author SHA1 Message Date
Umherirrender
171775e07b doc: Cleanup @param documentation
No extra sign needed between variable and description

Change-Id: Iaaaf62a3ffba7967aef8c31b121121b2830b74c4
2021-11-04 22:32:39 +01:00
Alexander Vorwerk
5aa1bf33f6 Make PageEditStash::checkCache() accept an UserIdentity
This allows using the already into PageEditStash injected UserFactory
instead of falling back to global state in DerivedPageDataUpdater.

Change-Id: I18f198d323c3ca001c6a0de91bc669180cd1d11c
2021-10-16 00:16:20 +02:00
Petr Pchelko
35f38e995b Remove User from LinksUpdate
This does a breaking change, but all (2) known usages
of the LinksUpdate::getTriggeringUser are satisfied
by UserIdentity.

Change-Id: I682ee65f7b3d30fe6c0fe76d5106857ddfa6da5d
2021-09-13 09:40:24 -07:00
James D. Forrester
df1e801cca Miscellaneous master -> primary switches for private functions and variables
Change-Id: I5c90822f1da6af7354ee7e2d67d579bd72bce8c3
2021-09-03 20:14:41 +00:00
Amir Sarabadani
66a4b414e5 Introduce concept of generateHTMLOnEdit() for ContentHandler
This way you can avoid rendering HTML and storing ParserCache entries

Bug: T285987
Change-Id: I3c7023b776f2a1e35dafdbb6ac0eb3eb73ae5fd4
2021-08-24 22:40:46 +02:00
Alexander Vorwerk
bf04b98483 DerivedPageDataUpdater: inject remaining services
Inject PageEditStash, TalkPageNotificationManager, MainWANObjectCache
and PermissionManager

Change-Id: I4b77390f785b6aa5251da4c8b32cd9d1433780f4
2021-08-11 10:26:07 +00:00
Petr Pchelko
b782a7e66d Move Content::preSaveTransform to ContentHandler
Create ContentTransformer to access ContentHandler::preSaveTransform through the service.
Prepare object to hold a data that required for ContentHandler::preSaveTranform params.

This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.

However, with the ContentHandler calling Content and
Content calling ContentHandler, and with the ProxyContent
trick to stop infinite recursion, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers. But won't really allow
hard-deprecation.

Bug: T287156
Change-Id: If6a2025868ceca3a3b6f11baec39695e47292e40
2021-07-29 18:06:02 +03:00
Roman Stolar
891cb86882 Remove Content::getSecondaryDataUpdates() and all usage of it.
Bug: T285729
Change-Id: I22d4e93b3eae652323c8527673d00103f2590bc7
2021-07-22 06:44:09 -07:00
Roman Stolar
b915e23d46 Remove Content::getDeletionUpdates() and all usage of it.
Bug: T285730
Depends-On: Iab6916134308c73f97c2c4fce2c11a08eab95442
Change-Id: If65db7bc768c6991935982d738f8a3a20d8b4c18
2021-07-22 12:40:18 +03:00
Petr Pchelko
691b128efb Remove deprecated ArticleEditUpdates hook
Change-Id: If3487ab495306ea4afef30398690a6bbeabc9ce4
2021-07-20 17:32:44 -07:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
DannyS712
19739de872 Remove some unneeded uses of full User objects
Change-Id: Ib86399445a77d3005f23ae87d87f3cf742b13b1f
2021-05-22 03:58:25 +00:00
DannyS712
f60ea069ba Remove remaining non-test uses of Revision objects
The following methods no longer support Revision parameters:
- CategoryMembershipChange::__construct
- ContentHandler::getUndoContent
- DerivedPageDataUpdater::prepareUpdate
- DifferenceEngine::getRevisionHeader

The following methods were removed entirely:
- Title::countAuthorsBetween

The following methods return arrays that formerly include
a 'revision' key that would emit deprecation warnings when
accessed and return a Revision object. The Revision object
has been removed from the arrays, and the 'revision-record'
key should be used to get the relevant RevisionRecord instead:
- PageUpdater::doModify
- PageUpdater::doCreate
- Parser::statelessFetchTemplate

The ParserOptions `templateCallback` option is a callback
that is called in Parser::fetchTemplateAndTitle() and should
return an array - the 'revision' key to that array used to
be a Revision object and was used if no 'revision-record'
was returned - it is now ignored.

Bug: T247143
Change-Id: I163ada88d649c75697aff4fa31a3a3c0bdef78b7
2021-05-04 13:10:22 -07:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00
James D. Forrester
f6667ab415 Remove ArticleEditUpdatesDeleteFromRecentchanges hook, deprecated in 1.35
Also move RC purging code.

Bug: T244613
Depends-On: I743b764ccd031df448cfac31a9bba3c60442d250
Change-Id: Ib455501c266f8482f56d08041de0f5beba651a0b
2021-04-21 14:38:59 -07:00
Umherirrender
78cc6d77ff build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I09a6175917090593e6e0055203a890c32bea03a5
2021-04-04 21:18:22 +02:00
daniel
cbae51aa0e PageUpdater: use UserIdentity where possible
Code performing edits should not need a full User object, a UserIdentity
should be sufficient.

This is an important step to enabling cross-wiki edits.

Bug: T275509
Change-Id: I357772799e82ea88b1b85b605f76ebefc19ebf21
2021-03-09 18:28:39 +01:00
Umherirrender
ef7fc91327 DerivedPageDataUpdater: Skip all data updates when page is deleted
There is nothing the updates can do,
LinksUpdate also fails if there is no id for the given title on master

Bug: T271356
Change-Id: I7fb690bec8dbfadf71eb9caacb4edbfe6b785e73
2021-02-17 22:54:08 +01:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Ostrzyciel
a47778d5c0 Add mw-reverted change tag
The tag is added to reverted edits as described in T254074.

Functionality:
* Adding the mw-reverted tag to reverted edits (duh)
* Limiting the maximum depth of the update through a config variable
(mitigation #2 from T259014).
* Only applying the reverted tag after the edit has been somehow
approved. Only the patrol subsystem currently implements this, but
there's a hook that extensions can use (mitigation #4 from T259014, more
explanation in T259103).
* When performing the delayed update, it is checked whether the reverted
edit was reverted itself. If so, the update is ignored. This is
probably the only way to make the feature work due to the lack of an
explicit "disapproval" mechanism other than reverting.
* The update is also ignored if the revert is marked as deleted.

Technical design:
* The update code is in RevertedTagUpdate.php, which is a deferrable
update, but is not used as such. It's separated to allow for better DI,
testing and better code reusability in the future.
* The update is queued / ran using the Job subsystem. The relevant job
is in RevertedTagUpdateJob.php
* PageUpdater determines whether the edit is approved or not and passes
that to the DerivedPageDataUpdater.
* The BeforeRevertedTagUpdate hook lets extensions decide whether the
update should be ran right away or await approval.
* DerivedPageDataUpdater checks whether the edit is a revert and if so
either enqueues the job (if it's auto-approved) or caches the EditResult
for later use (if it needs approval).
* RevertedTagUpdateManager allows for easy re-enqueueing of the update
for extensions. Thus, it has a very minimal interface.

Other notes:
* The unit testing setup for RevertedTagUpdate is a bit complicated,
but it was the only way I could make this class testable while using
the static ChangeTags class.

Bug: T254074
Depends-On: I86d0e660f0acd51a7351396c5c82a400d3963b94
Change-Id: I70d5b29fec6b6058613f7ac2fb49f9fad9dc8da4
2020-08-31 13:40:50 +00:00
Ed Sanders
7683f7d839 Use strict (in)equality with namespaces constants when LHS is definitely an integer
Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
2020-07-31 18:03:28 +01:00
DannyS712
f47b779f56 DerivedPageDataUpdater::prepareUpdate deprecate passing a Revision
Revision can be in the $options array
Callers also need to be updated

Bug: T255909
Change-Id: I22aa89aaab546b98b516cf344655589550a13457
2020-06-23 23:48:30 +00:00
DannyS712
a6d16bd03d Remove unneeded creation of revision objects
Clean up some technical debt; use MutableRevisionRecord instead of
manually constructing a Revision from an array, remove last uses of
RevisionStoreDbTestBase::revisionToRow and remove the method.

Each file can be reviewed separately (except that the removal of
revisionToRow depends on replacing its usage)

Bug: T246284
Change-Id: I0bdc069b21a5c41ef8f9e972c5b17ff189d4a741
2020-06-10 09:09:55 +00:00
jenkins-bot
2db34afa49 Merge "Replace core uses and hard deprecate Parser(Options) Revision methods" 2020-06-03 23:58:34 +00:00
jenkins-bot
08dae812d0 Merge "resourceloader: Use RevisionRecord in WikiModule::invalidateModuleCache" 2020-06-03 23:00:31 +00:00
DannyS712
88b981e831 resourceloader: Use RevisionRecord in WikiModule::invalidateModuleCache
Replace uses of Revision with RevisionRecord; passing a Revision is not
supported anymore, and the method is now marked as @internal.

Decide whether to purge the cache based on the content models of the
revisions' main slots, rather than their formats. The content format
is more difficult to determine on a RevisionRecord than with Revision.
The new interface encourages use of content models instead, so we use
that from now on as well.

Bug: T249561
Bug: T250981
Change-Id: I7ad27f52c0975b0c22f2aa9248c3fcf6d5b2ed8f
2020-06-03 22:39:17 +00:00
DannyS712
381d873a8b Replace core uses and hard deprecate Parser(Options) Revision methods
Bug: T249384
Change-Id: Iff10e76120eb8b6b4fbb939182dede83c86d3da2
2020-06-03 05:55:35 +00:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
A terminating line break has not been required in wfDebug() since 2014,
however no migration was done. Some of these line breaks found their way
into LoggerInterface::debug() calls, where they mess up the formatting
of the debug log.

So, remove terminating line breaks from wfDebug() and
LoggerInterface::debug() calls.

Also:
* Fix the stripping of leading line breaks from the log header emitted
  by Setup.php. This feature, accidentally broken in 2014, allows
  requests to be distinguished in the log file.
* Avoid using the global variable $self.
* Move the logging of the client IP back to Setup.php. It was moved to
  WebRequest in the hopes that it would not always be needed, however
  $wgRequest->getIP() is now called unconditionally a few lines up in
  Setup.php. This means that it is put in its proper place after the
  "start request" message.
* Wrap the log header code in a closure so that variables like $name do
  not leak into global scope.
* In Linker.php, remove a few instances of an unnecessary second
  parameter to wfDebug().

Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
2020-06-03 12:01:16 +10: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
Clara Andrew-Wani
b3a5c7c0d5 Use new TalkPageNotificationManager
Bug: T239640
Change-Id: I7c06d145854ab39faaef528e169f6b51de1c8d99
2020-05-15 12:35:45 -04:00
DannyS712
4721717527 Replace uses and hard deprecate Article:: and WikiPage::getRevision
Bug: T250532
Bug: T239975
Change-Id: Ic8f2baa0ac805d5196a7107bdc7a1abb36eba139
2020-04-20 23:06:48 +00:00
DannyS712
3a024ec369 WikiPage::onArticleEdit - accept a RevisionRecord
Using Revision is hard deprecated

Bug: T249561
Change-Id: I4b639f8adba329991afbcff26c7223e325225055
2020-04-10 23:09:50 +00:00
DannyS712
c75a713479 Support RevisionRecords in User Newtalk methods, deprecate Revision
Bug: T246284
Change-Id: I409e13657e52d7d286de1b7c728260aecee43220
2020-04-03 23:39:56 +00: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
Aaron Schulz
1f4efc6c34 Add RefreshSecondaryDataUpdate and use it in DerivedPageDataUpdater
This class implements EnqueueableDataUpdate and can be pushed as a
job if it fails to run via DeferredUpdates.

Unlike a1f7fd3ada, make RefreshSecondaryDataUpdate skip failing
updates in doUpdate(). Instead of throwing the first exception from
any update, log any exceptions that occur and try all the other
updates. The first error will be re-thrown afterwards.

Also, make sure that each DataUpdate still has outer transaction
scope. This property is documented at mediawiki.org and should not
be changed.

Add integration tests for RefreshSecondaryDataUpdateTest.

Bug: T218456
Bug: T206283
Change-Id: I7c6554a4d4cd76dfe7cd2967afe30b3aa1069fcb
2020-03-11 00:42:48 -07:00
DannyS712
2e3bdb3498 Miscellaneous documentation updates
Update references from .txt to .md when files have moved, a few other
tweaks, no changes to code.

Change-Id: I0bfd38c47b9fb0fc11ae98a0a674af66fb4c5a84
2020-02-16 04:38:38 +00:00
James D. Forrester
cafe286e2b Deprecate the ArticleEditUpdates hook
Change-Id: Ie85a46846315999ebaab1e1b38265937f4b2c79e
2020-02-08 20:29:35 +00:00
James D. Forrester
6a7ab1ed04 Deprecate the ArticleEditUpdatesDeleteFromRecentchanges hook
Bug: T244613
Change-Id: I2bb1645a8b5d99a5a3c4425f2bc0e8c3f524d4e8
2020-02-07 15:35:08 -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
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08: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
Max Semenik
8a98dd9d59 Convert some private static arrays to constants
Remove @since for some private ones as we don't guarantee anything
about private class members.

Change-Id: Ifb898353c02082e9ef69d67f69339345c6cd154d
2019-10-16 01:30:54 +00:00
Petr Pchelko
7b4eafda0d Replace usages of deprecated User::isAllowed. Step 2.
Bug: T220191
Depends-On: I509cd88355cfd0cc074f4135ec86399b4075f89f
Change-Id: I2341e6f1d108c92924620fba3c64ec090cb09918
2019-09-11 16:00:03 -07:00
jenkins-bot
e09547f59b Merge "Remove title protection correctly for undeletions and imports" 2019-08-17 09:27:34 +00:00
Petr Pchelko
e3ecfe4544 Check all slots in DerivedPadeDataUpdater::isCountable.
For example when the page is moved, the slots are not actually
modified, so countability of the page after the update should
not be based only on modified slots, but instead on all the page
slots.

Bug: T212706
Change-Id: Ie352ec9307b89b04af09ed85b542ca2907856bbf
2019-08-16 09:55:01 -07:00
GeoffreyT2000
00104e2c0e Remove title protection correctly for undeletions and imports
Undeletions and imports can both produce "new" pages with more than
1 revision. The fact that $options['created'] for the associated
DerivedPageDataUpdater instance is unexpectedly changed to false is due
to the fact that the latest revision often has a nonzero rev_parent_id.
This causes WikiPage::onArticleCreate not to be applied correctly, and
so title protection is not correctly removed. The part about "created"
being forced is therefore being fixed.

Bug: T200088
Change-Id: I8c899893486976285eb6fac87d641e93a616676d
2019-08-16 14:13:48 +00:00
David Causse
bc0de57e75 Simplify SearchUpdate constructor and hard deprecate some param types
Change-Id: I5677041169402014f1afc1a9012460c760ca24b6
2019-08-01 17:24:42 +02:00
jenkins-bot
1cc50ab8f5 Merge "Migrate various callers away from wfWikiId() to WikiMap" 2019-07-12 17:33:51 +00:00