Commit graph

586 commits

Author SHA1 Message Date
daniel
3c50afa46b Replace "@stable for subclassing" with "@stable to extend"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
2020-07-13 11:00:30 +02:00
daniel
aedc93fdb0 Mark remaining eligible classes as stable for subclassing
This classes were found by surveying concrete classes derved from base
classes in core.

Bug: T247862
Change-Id: I231752aaad26e2ab3f097301e449b31e723590f0
2020-07-10 15:02:27 +02:00
daniel
102c9573b3 Mark exceptions as @newable
Exceptions classes are nearly always value objects, and should in most
cases by newable.

Bug: T247862
Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
2020-07-08 17:51:38 +00:00
daniel
128565505c Mark additional classes as newable for now.
The following glasses are marked as newable per the
Stable Interface Policy, even though logically, they should not be
newable. This is done for classes that are currently instantiated
by extensions, and lack an alternative.

A better way for obtaining an instance of these classes should be
created in the future. At that point, direct instantiation should
be deprecated and replaced.

- includes/ApiMain.php - needs factory
- includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern
- includes/GitInfo.php - should become a stateless service
- includes/logging/LogPage.php - should become a stateless service or use command pattern
- includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern
- includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory
- includes/context/RequestContext.php - needs to be narrowed down, and should use a factory
- includes/search/SearchHighlighter.php - should have a factory
- includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory
- includes/user/User.php - should at least get a factory method for anons
- includes/diff/Diff.php: needs a TextDiffGenerator service or a factory
- includes/EditPage.php: needs a factory

Bug: T247862
Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
2020-07-08 18:06:12 +02: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
DannyS712
94169ee873 Whitespace cleanup: Use tabs for indentation, avoid double spaces
Change-Id: I346073b59d283029bd6666356c62c81e687ea5e6
2020-06-27 07:53:07 +00:00
daniel
f59bf8a22f Use @internal instead of @private per policy
https://www.mediawiki.org/wiki/Stable_interface_policy mandates the use
of @internal. The semantics of @private was never properly defined.

Bug: T247862
Change-Id: I4c7c6e7b5a80e86456965521f88d1dfa7d698f84
2020-06-26 14:14:23 +02:00
DannyS712
1359f1533c DifferenceEngine: Don't pass false to DiffTools hook
Bug: T256298
Change-Id: I2aeb96a63c30ed226d8d2f05a78baf37c50c6f4e
2020-06-25 01:20:03 +00:00
DannyS712
72010ca818 DifferenceEngine: Call DiffTools hook with correct parameter order
mNewRevisionRecord is meant to be the first parameter, and
mOldRevisionRecord the third, not the other way around

Bug: T256298
Change-Id: I030a9834635a85ad464e5826926c26b41a9c31b0
2020-06-24 22:05:55 +00:00
jenkins-bot
1dd24c56e8 Merge "diff: Remove unneeded false check" 2020-06-24 09:29:25 +00:00
DannyS712
5abd50b925 Add HistoryTools and DiffTools hooks
Bug: T255494
Bug: T255495
Change-Id: Ib2ab2e26a95affdd1dfa6b945f752157580ea2d3
2020-06-23 17:30:22 -07:00
Umherirrender
eb095ad311 diff: Remove unneeded false check
$difftext is always a string since
I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Init with empty string and than only concat is used

Change-Id: Ie606a441d8c59313505640c25406a7c59433b5cc
2020-06-22 22:36:04 +02:00
DannyS712
a5dc0331d0 Add new DifferenceEngineViewHeader hook to replace DiffViewHeader
Bug: T255769
Change-Id: I8adf51fe641c88c9b37080af065a0a9cd920de44
2020-06-18 13:25:29 +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
Timo Tijhof
45da13803d resources: Bundle ajax patrol and ajax rollback code
Create a small "curate"-related bundle of moderation and review
enhancements. The overlap between the two is not perfect, but the
scripts are small enough that it doesn't seem worth trying to
create separate bundles for.

Change-Id: Ibd00e0eddfafc57323b147e225ee668528dc1c1c
2020-05-28 07:22:07 +00:00
DannyS712
9571defd8e Remove DifferenceEngine::$mNewRev and $mOldRev
Public access was deprecated in 1.32. Protected access is not
covered under the deprecation policy.

Bug: T250761
Bug: T250714
Bug: T249021
Bug: T250579
Change-Id: I47adbc316236be80672416a5c363a99c3dd53400
2020-05-26 20:51:23 +00:00
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
Reedy
988174411c Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: If1335359b545c36fc979676c3e88d87628f9389e
2020-05-16 00:51:31 +01:00
Reedy
1af2020739 Fix numerous Squiz.Scope.MethodScope.Missing
Change-Id: I7a5aa8555e94a0bcb97b37ec6f8ca854de7c5575
2020-05-15 21:12:30 +00:00
Tim Starling
550f5930f2 Hook interface type fixes, to fix Phan errors
Phan flagged a lot of incorrect type hints when run against the call
site migration patch.

Bug: T240307
Change-Id: I698de5536446c241b200430198b21b72763b0c69
2020-05-05 11:22:04 +10:00
jenkins-bot
c696170cbf Merge "Pass RevisionRecord to DifferenceEngine::getRevisionHeader" 2020-04-27 20:48:26 +00:00
jenkins-bot
89f14cf3e1 Merge "Hook interface doc comment followup" 2020-04-27 19:40:14 +00:00
DannyS712
dd8553d550 Pass RevisionRecord to DifferenceEngine::getRevisionHeader
Hard deprecate using Revision objects

Bug: T249561
Change-Id: Icf543635216ed06f3448a76faa97b459aa07f8e5
2020-04-27 18:51:05 +00:00
DannyS712
511b528227 DifferenceEngine::getRevisionHeader - accept a RevisionRecord
Using Revision is not deprecated yet

Bug: T250608
Depends-On: Ic13220b3120dbecd83685ce3553c5b5a6c1e7fdd
Change-Id: I648cb62460f6ca20217a21c462e842d82ae06613
2020-04-26 23:41:47 +00:00
jenkins-bot
f898b49c98 Merge "docs: Hook interface doc comment review" 2020-04-21 06:41:19 +00:00
jenkins-bot
cc89a81451 Merge "Automatically generated hook interfaces" 2020-04-21 00:07:41 +00:00
Tim Starling
0b7295a5cd Hook interface doc comment followup
Mostly just narrower array types. A handful of other errors fixed.

Change-Id: Ied79d9e389867911bf83696dbb47f43305f8be7b
2020-04-21 09:12:23 +10:00
apaskulin
c44488f725 docs: Hook interface doc comment review
Edited doc comments for hook interfaces to improve
consistency and add type hints.

Bug: T246855
Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
2020-04-21 09:10:08 +10:00
Tim Starling
f5aaf75ad1 Automatically generated hook interfaces
Add hook interfaces which were generated by a script which parses
hooks.txt and identifies caller namespaces and directories.

Hook interfaces are mostly placed in a Hook/ subdirectory
relative to the caller location. When there are callers in multiple
directories, a "primary" caller was manually selected. The exceptions to
this are:

* The source root, maintenance and tests, which use includes/Hook. Test
  hooks need to be autoloadable in a non-test request so that
  implementing test interfaces in a generic handler will not fail.
* resources uses includes/resourceloader/Hook
* The following third-level subdirectories had their hooks placed in
  the parent ../Hook:
    * includes/filerepo/file
    * includes/search/searchwidgets
    * includes/specials/forms
    * includes/specials/helpers
    * includes/specials/pagers

Parameters marked as legacy references in hooks.txt are passed
by value in the interfaces.

Bug: T240307
Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
2020-04-20 13:31:05 +10:00
DannyS712
0f826d1f73 Replace uses and hard deprecate Revision::newFromTitle
Also fixed a use of ::newFromId in benchmarkParse and Parser

Bug: T249183
Change-Id: I3219a72f1085836205dc497e2236b52db24d7c16
2020-04-18 04:47:10 +00:00
DannyS712
eeef56ec49 Fix remaining uses and hard deprecate Title::(get|count)AuthorsBetween
Bug: T249561
Bug: T249183
Change-Id: Ib25de71d4870c2832e06efc46ce372695c5031fd
2020-04-18 02:03:24 +00:00
DannyS712
af7f397ccc Pass RevisionRecord to Linker methods
Hard deprecation of passing Revision objects will follow soon,
but until that is ready core calls can be updated

There is some code cleanup that could be done around the calls, but
to simplify review no other changes are made.

Bug: T249561
Change-Id: Ifcfb3811650decffeaa87dc033c41fd1710b47a6
2020-04-18 01:24:54 +00:00
jenkins-bot
334eb94f20 Merge "Use MediaWikiServices::getStatsdDataFactory" 2020-04-17 01:03:56 +00:00
Ed Sanders
40fdd9b6bc Apply editfont preference to diff rendering
Bug: T250393
Change-Id: I07dd6f78fdd6b07b349c0d08942a374d4d855af5
2020-04-16 14:53:59 +01:00
Umherirrender
62747a98cc Use MediaWikiServices::getStatsdDataFactory
Change-Id: I219225ad8232c0726ea18375e43aad6b524d67d0
2020-04-15 21:52:47 +02:00
DannyS712
fda65e7a27 Replace remaining uses and hard deprecate Revision::newFromArchiveRow
Bug: T248772
Change-Id: I44d0573b8af14d55e1c7423197dfae3cd55d7417
2020-04-01 20:18:33 +00:00
jenkins-bot
4df90065db Merge "Make use of DiffOp::norig/nclosing() and update tests" 2020-04-01 08:24:06 +00:00
DannyS712
1d4df4f221 Hard deprecate Revision::getQueryInfo and ::getArchiveQueryInfo
Bug: T246284
Change-Id: I708f265aac3016e34d02936cf5dff98a3036ef0f
2020-03-26 23:53:19 +00:00
Thiemo Kreuz
42a03b9752 Make use of DiffOp::norig/nclosing() and update tests
The names of these methods are a little strange, that's probably why
we missed them before.

I tried to update closely related test cases, make use of PHP7 type
hints, as well as yield where it feels it makes sense.

Change-Id: I1cf27138e1e47f713739b6fd53101b9ec7d38fe7
2020-03-25 15:17:17 +00:00
Thiemo Kreuz
7a4df9b019 Remove auto-generated and empty lines in comments
… and add the missing newline after the initial <?php.

Change-Id: I83bbbb1504e4b2bd97eec63c7626d34c655c3197
2020-03-17 09:55:24 +01:00
DannyS712
78bc3ae255 Hard deprecate Revision::userCan
Replace remaining uses outside of tests, hide deprecated in tests

Bug: T247259
Change-Id: I91dfb46ed6864ee89d968aea8ec93b5ea2f8389e
2020-03-11 02:10:52 +00:00
DannyS712
909f0bef6e Replace calls to Title::getUserPermissionsErrors (part 5)
This does //not// fix all calls in core.

Bug: T244929
Change-Id: I02ffcca31fa0bdc6bffddf21e82f4ff5e9ab5374
2020-02-26 03:00:33 +00:00
jenkins-bot
4dbc276487 Merge "Remove ArticleContentViewCustom hook, deprecated and unused" 2020-02-13 05:13:11 +00: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
DannyS712
f14fad3538 Remove ArticleContentViewCustom hook, deprecated and unused
Bug: T241351
Change-Id: Ie37ed9265511e3051ea60c6898febb567d5283df
2020-02-06 19:55:16 +00:00
Matěj Suchánek
3ce567d8ac Replace Linker::link usage with LinkRenderer in includes
Needs one unit test to become integration again :(

Bug: T149346
Change-Id: I62fc566dfb542939431fd4a135c05e0924c70dbf
2020-01-11 11:20:17 +01:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
jenkins-bot
554feecbb4 Merge "Inline diffs upstreamed from MobileFrontend to core." 2019-12-08 09:01:48 +00:00
jdlrobson
1c2de3d397 Inline diffs upstreamed from MobileFrontend to core.
A new inline mode is provided for diffs.
It is only available when wikidiff2 is installed.
There is no PHP implementation (one can be added later if
necessary)

For now, it is accessed by passing diff-type as a query string parameter
e.g ?diff-type=inline
A control for switching between the two is added as a follow up.
see Ie9bb17789d90b7492559782021937f3f3e4356f8

* The final method getSlotDiffRenderer now takes a second parameter
options
* The method `getSlotDiffRendererInternal` is deprecated and
replaced with the more flexible `getSlotDiffRendererWithOptions`
This has potential to be a breaking change but is unlikely to impact
any existing clients.

Note: PHP implementation can be added later if necessary

Bug: T117279
Change-Id: I4f81c8ccf253dd4aa6cf43c3fad257b4b0dd1ebd
2019-12-06 01:08:10 +00:00