Commit graph

472 commits

Author SHA1 Message Date
Matěj Suchánek
6cac207f15 Use LinkRenderer instead of building link HTML manually
Change-Id: I3e9fac92e78aa599fdaa1a6061af363cd48eb554
2021-02-12 12:35:32 +01:00
jdlrobson
ddb0c53f46 mw-warning class is replaced with warningbox
The styles can be removed as there are no caching implications here
If a skin is loading `legacy` feature or providing its own (e.g
Minerva)

Non-Wikimedia skins loading content but not legacy will lose
styling here, but that will be consistent with other message
boxes in the interface.

Bug: T269797
Change-Id: I5cfa9d83bedd2786d65d835c1f7623b7a61317c4
2020-12-09 13:27:52 -08:00
Umherirrender
692148fd62 Improve and add documentation to diff related classes
Change-Id: Ic10c700e970018fa0b9a219d96d56908b0298d71
2020-11-22 19:09:02 +00:00
Umherirrender
96cefbccfd Use existing RevisionStore in diff related context
RevisionStore includes the RevisionLookup, use the same instance

Change-Id: Ia299dae4bfb75c06ae2fca099e780ea6d2acecf5
2020-11-14 02:52:36 +01:00
Umherirrender
36b297560d Replace deprecated WikiPage::factory in DifferenceEngine
Change-Id: I2f32d9169d0bef5ed5cd433c05e2257ab7bf95f2
2020-11-11 22:36:36 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
Thiemo Kreuz
fd7363a1e1 Fix broken PHPDoc comments that don't start with /**
Change-Id: I8db56ff0f73873864dde260e51adcd729aa74e94
2020-07-23 16:09:41 +00: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
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
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
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
DannyS712
1d4df4f221 Hard deprecate Revision::getQueryInfo and ::getArchiveQueryInfo
Bug: T246284
Change-Id: I708f265aac3016e34d02936cf5dff98a3036ef0f
2020-03-26 23:53:19 +00: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
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
Brad Jorsch
a8cbf85d1d DifferenceEngine: Don't try counting revs between deleted revs with different page IDs
Recent changes have caused the method for counting the number of
revisions in between the two sides of a diff to throw an error when the
revisions have different page IDs.

This blows up some cases of trying to get a difference between deleted
revisions, as the page IDs on the deleted revisions might not match
and/or might not match the current ID returned by the Title object.

Bug: T237709
Change-Id: I415f7ebb57fa4e879396b0db0e3a79edc2880be5
2019-11-20 13:21:46 -05:00
jenkins-bot
570c19f1f5 Merge "Don't calculate amount of inbetween revisions for MCR undo" 2019-11-06 14:52:15 +00:00
jenkins-bot
6af95728ef Merge "Add $wgDiffEngine" 2019-11-05 22:25:15 +00:00
Brad Jorsch
f3058c81b9 Add $wgDiffEngine
The immediate use case is for testing, where some tests need to use the
PHP implementation even when wikidiff2 is installed.

Bug: T237049
Change-Id: I41dc4c0933429065d7638f518ec31f0a056afc41
2019-11-05 10:38:52 -05: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
Matthias Mullie
7fe98fb56c Don't calculate amount of inbetween revisions for MCR undo
Ib404d29a662de7736b50a1d07380f651d332ad6b introduced a new sanity
check in RevisionStore::countRevisionsBetween to check whether
the ids are not null (otherwise, they're considered unsaved)

For MCR undo actions, diffs could be generated for unsaved revisions
(where one revision is a not yet pre-existing combination where
some slots remain unchanged, but some slot gets undone)

The existing if statement here was already trying to guard against
unsaved revisions, but was doing so in a way different from the
new checks in RevisionStore::countRevisionsBetween - even though this
was documented to only diff saved revisions, it wasn't checking
thoroughly enough, and an exception would crop up later.

Bug: T236320
Change-Id: If34766675f50b67d8b0788a6eab07d8d4e6fe183
2019-11-04 11:17:37 +01:00
jenkins-bot
678157c01a Merge "Permissioning refactor of DifferenceEngine" 2019-11-01 04:02:40 +00:00
jdlrobson
93575bf125 Permissioning refactor of DifferenceEngine
In preparation for adding the MobileFrontend DifferenceEngine
some light refactoring of the uber-function showDiffPage is
required.

This begins by extracting several helper functions that will
be used inside the new InlineDifferenceEngine class (and addressing
the FIXME's inside MobileFrontend's code.

Hopefully the new code is much more readable by explaining the
complicated logic that lives inside the showDiff function

Bug: T117279
Change-Id: Iede69d1b87ac100472087584968df2d479e13f60
2019-10-30 14:48:53 -07:00
Yaron Koren
b10d0fa09d Fix for ArticleRevisionViewCustom hook in DifferenceEngine.php
Was missing a parameter, which actually made this hook unusable.

Bug: T236628
Change-Id: I6e260cd49f7083f34d4218712edf7d91d2f11ee9
2019-10-28 15:43:38 +00:00
jenkins-bot
78a2b8f485 Merge "Fix new phan errors, part 5" 2019-10-20 01:39:44 +00:00
Daimona Eaytoy
d3252fc870 Fix new phan errors, part 5
Some of the errors are suppressed because they're phan false positives.
The idea behind this is that they'll be fixed in a future version of
phan, and we'll just have to remove the suppressions.

Note: I'm disabling UnusedPluginSuppression so that we can start suppressing
issues even if they're still disabled. The sniff should be re-enabled
as soon as we upgrade phan.

Bug: T231636
Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
2019-10-18 20:45:53 +00:00
Petr Pchelko
6eb67c752e Move countRevisionsBetween from Title to RevisionStore
Bug: T235666
Change-Id: Ib404d29a662de7736b50a1d07380f651d332ad6b
2019-10-17 08:02:26 -07:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.

Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
2019-10-10 11:53:58 +02:00
James D. Forrester
5b3bbd5ade Drop strings for wgExternalDiffEngine, deprecated in 1.27 and 1.32
Also move the 'unit' test into integration, given it tests code
using globals.

Change-Id: Ie039cae9b5d2870c18a6deefec9a73de522dd847
2019-10-03 22:09:38 +00:00
Petr Pchelko
56c21d059c Remove usages of Title::get{Previous,Next}RevisionId
The methods were deprecated since 1.34.

Change-Id: Ib95ac1ba36a8ffd6b71ed67642d8abb2e3538bae
2019-09-13 09:49:13 -07:00
Daimona Eaytoy
cbf0404caa DifferenceEngine: Use quickUserCan for display of rollback link
Title::userCan is too expensive for this, as it queries the master DB
just to decide whether a link should be shown.
The DBPerformance warning for this is seen roughly 8000 times per day on
logstash.

Bug: T232258
Change-Id: I33eab493273ed4790645e338c83993043e76e1d7
2019-09-09 15:30:44 +00:00
daniel
8041b1ff89 DifferenceEngine: show undo links for non-text content
In Ia94521b78 I introduced code that would suppress undo links in diffs
of non-textual content. However, extensions that define non-textual
content, such as Wikibase, may override action handles to provide undo
functionality. So my reasoning for removing these links was flawed.

Bug: T232214
Change-Id: I0316d8c0683b0782b9940e0e1e8f70d5bcb6b468
2019-09-06 15:58:31 +02:00
Petr Pchelko
f1914810a7 Remove usages of Title::quickUserCan
Change-Id: Ifa53e0ec800e23dc4184d133a100fb9378dfee9e
2019-08-29 11:48:30 -07:00
daniel
6906a7728c Add UnknownContentHandler.
UnknownContentHandler can be configued to handle models that
belong to extensions that have been undeployed:

  $wgContentHandlers['xyzzy'] = 'UnknownContentHandler';

This way, no errors will be thrown when trying to access
pages with the unsupported model. Instead, an error message is
shown, and editing is prevented.

This patch also improves handling of non-editable content in
EditPage and in DifferenceEngine.

Bug: T220608
Change-Id: Ia94521b786c0a5225a674e4dc3cb6761a723d75b
2019-08-29 10:43:11 +00:00
Petr Pchelko
1d286560d2 Replace User::isAllowed with PermissionManager.
Covers root includes, actions, api, block, changes,
changetags, diff and PermissionManager itself.

Bug: T220191
Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
2019-08-20 14:43:51 -07:00
Umherirrender
2664eeb632 Clean up spacing of doc comments
Align the doc stars and normalize start and end tokens

Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
2019-08-05 22:29:50 +00:00
jdlrobson
6b3a9c0521 Don't double wrap rollback links
Bug: T228766
Change-Id: Iaca54e1ceefc73815fe3d9898ca490b74d11dac6
2019-07-23 12:07:47 -07:00
Derick Alangi
c5b7101a15 Avoid usage of deprecated Revision::* constants
Change-Id: Ibb55d5a01f997f9c79bcf2f5e09d4f02d22152d2
2019-07-21 17:26:48 +01:00
Derick Alangi
339211a1ea Avoid usage of deprecated Revision::* constants, use RevisionRecord
Change-Id: I872fc89e5c02dd6a3ae9cd7e76640b95dc33f514
2019-07-21 15:03:03 +01:00
Máté Szabó
6420c79320 Migrate remaining usages of Title::userCan() to PermissionManager
T208768 introduced the PermissionManager service that can now be used
for page specific permission checks. This change replaces remaining calls
to Title::userCan() with the new service in MediaWiki core.

Bug: T220191
Change-Id: Ie45e0cb6aa49a8c66147b470946161fc18160fc1
2019-06-03 13:03:46 +02:00
Adam Wight
2eec94991b Deprecate $wgWikiDiff2MovedParagraphDetectionCutoff
Bug: T194272
Change-Id: I174192dc2b91409e023c06b054bc1bba8bfc571f
2019-05-22 15:42:20 +02:00
Derick Alangi
7f5a204e42 diff: Wrap condition around brackets for more readability
Also, as I'm touching this line, fixing the is_null() check to
finally clean this entire line up once and for all.

Change-Id: I573972519796f3eedaf950fa953b9df6b6824379
2019-04-13 19:18:57 +01:00
Fomafix
14d9e80ba4 Fix order of @var parameter in PHP
Replace

 @var $foo type

by

 @var type $foo

Change-Id: Iec8b90ffea4028a1005daef422b7c4ec38c2715f
2019-04-08 18:37:56 +02:00
Aaron Schulz
a26eee40e0 Avoid use of deprecated ObjectCache::getMainWANInstance method
Change-Id: I429e68c8642a00afa812f5ae900c1fb4f8308528
2019-03-01 02:38:55 +00:00
jdlrobson
0e1edec723 Apply the pseudo-css selector rules to diff and changelist pages
The styles that we are applying on changelist pages should also
apply on diff pages. This generalises the rules into a new
module.

To avoid problems with cached HTML mediawiki.special.changeslist
temporarily loads resources/src/mediawiki.interface.helpers.styles.
This will be removed after the change has been in production for a
week.

Bug: T212613
Change-Id: I6aad563e48f41c783df8b176a4f437e60a1255cc
2019-02-21 15:54:46 -08:00
Brad Jorsch
02195c7a81 DifferenceEngine: Allow cache hits for empty diffs
PHP considers the empty string as falsey, so check for a string
result instead.

Bug: T216554
Change-Id: I3b7d1199acbfede8a95761c5cb1c797b9a3d64cb
2019-02-19 15:55:44 -05:00
Fomafix
04370ccb08 Remove double check of $oldRevision
The

 if ( $oldRevision )

above already do the same check.

Change-Id: Ibbd5b6209d67f195b6b7431bccc31c4401f0a799
2019-02-08 14:05:13 +01:00
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Thiemo Kreuz
4b71077646 Remove a few obscure "done" and "empty" comments
These don't add any knowledge to what is already obvious from the
code, I find.

Change-Id: Ia613b6a059f78dbeefdfd020899bd1a6e239a731
2019-01-30 20:35:14 +00:00
Umherirrender
ca06a63f3b Use ContextSource::getConfig instead of globals
Change-Id: I26dd9b1efc0292bbe0044d823f639a2ac5e339dd
2019-01-01 11:20:57 +00:00
jenkins-bot
8beca8a8fe Merge "Migrate SpecialUndelete and Diff from tag_summary to change_tag" 2018-12-12 22:30:55 +00:00
Amir Sarabadani
484c726c09 Migrate SpecialUndelete and Diff from tag_summary to change_tag
There is some code duplication that should be factored into ChangeTags
but it can be done later.

Bug: T209525
Change-Id: Ie929d541754634a7be15cbb87da1d9db1f05bf0c
2018-12-03 18:07:11 +01: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
Fomafix
59502c9ae7 Force type Language for $lang of DifferenceEngine::setTextLanguage
Change-Id: I77e7116f81072fa42f580552e7b94323cfe31856
2018-10-17 06:17:28 +02: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
4461aa6e4f Don't show unsaved revision in DifferenceEngine::renderNewRevision.
There was a conditional that was documented to make the method bail out
if the current revision was unsaved, but it was missing the actual return
statement.

Note that preview code in EditPage does not use
DifferenceEngine::renderNewRevision.

Change-Id: I86a25e9464435ac17c72f78f7ce1f354adf3d055
2018-09-21 13:38:56 +00:00
daniel
4835a75ec5 Use RevisionRenderer for rendering ParserOutput
Bug: T174035
Bug: T174036
Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
2018-09-11 15:25:39 +00:00
jenkins-bot
a5b5217300 Merge "DifferenceEngine: use a fake title when there's no real title" 2018-09-05 12:18:34 +00:00
jenkins-bot
c112c30346 Merge "Fix DifferenceEngine revision loading logic" 2018-08-24 18:24:08 +00:00
Gergő Tisza
b7ed112908
Fix DifferenceEngine revision loading logic
Bug: T201218
Bug: T202454
Change-Id: I867900190cb45b983e89769c7fc0f965e2651918
2018-08-24 13:20:07 +02:00
Brad Jorsch
1ab2f7a56b ApiComparePages: Update for MCR
The main external change here is that it can now return diffs per slot,
and the various parameters for providing text are deprecated in favor of
templated per-slot versions.

Also, this deprecates the 'fromsection' and 'tosection' behavior
introduced for T183823 (extracting a section's content for the diff) in
favor of the more logical behavior requested in T185723 (expanding
'fromtext-{slot}'/'totext-{slot}' as if for a section edit).

Bug: T200569
Bug: T183823
Bug: T185723
Change-Id: I700edfa766bbc320887f2e0b7507fcdb11e72cdc
2018-08-23 14:56:10 +00:00
Gergő Tisza
4a09b9ed52
DifferenceEngine: use a fake title when there's no real title
Bug: T202454
Change-Id: I9ee90acc833de93b5fa2579b5debc9637c9e9c5b
2018-08-23 16:23:05 +02:00
Gergő Tisza
d31580eeb0
[MCR] Render multi-slot diffs
Move logic for rendering a diff between two content objects out of
DifferenceEngine, into a new SlotDiffRenderer class. Make
DifferenceEngine use multiple SlotDiffRenderers, one per slot.

This separates the class tree for changing high-level diff properties
such as the header or the revision selection method (same as before:
subclass DifferenceEngine and override ContentHandler::getDiffEngineClass
or implement GetDifferenceEngine) and the one for changing the actual
diff rendering for a given content type (subclass SlotDiffRenderer and
override ContentHandler::getSlotDiffRenderer or implement
GetSlotDiffRenderer). To keep B/C, when SlotDiffRenderer is not overridden
for a given content type but DifferenceEngine is, that DifferenceEngine
will be used instead.
The weak point of the scheme is overriding the DifferenceEngine methods
passing control to the SlotDiffRenderers (the ones calling
getDifferenceEngines), without calling the parent. These are:
showDiffStyle, getDiffBody, getDiffBodyCacheKeyParams. Extensions doing
that will probably break in unpredictable ways (most likely, only
showing the main slot diff). Nothing in gerrit does it, at least.

A new GetSlotDiffRenderer hook is added to modify rendering for content
models not owned by the extension, much like how GetDifferenceEngine
works.

Also deprecates public access to mNewRev/mOldRev and creates public
getters instead. DifferenceEngine never supported external changes to
those properties, this just acknowledges it.

Bug: T194731
Change-Id: I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Depends-On: I04e885a33bfce5bccc807b9bcfe1eaa577a9fd47
Depends-On: I203d8895bf436b7fee53fe4718dede8a3b1768bc
2018-08-20 15:39:12 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Gergő Tisza
2300ef7ec4 Deprecate $wgExternalDiffEngine = 'wikidiff2'
The value 'wikidiff2' for $wgExternalDiffEngine was obsoleted in
I32b670ebf6 but not formally deprecated. Let's do that now.

Change-Id: Ie5ccd3895544cf393885b84d38eca6003c79e8ad
Depends-On: I33c6207cfc5fb66987d31818bc27055f597d28c7
2018-07-26 11:49:32 +00:00
Gergő Tisza
c767dfdea0
Deprecate public access to some DifferenceEngine properties
These had no business being public in the first place and there is
no usage in Gerrit. In case something does use them, it will probably
be broken by the refactoring that's soon to come, so the deprecation
warning makes it easier to figure out where the problem lies.

Change-Id: I72ba5cfbf91f4af16028ba4f8619df6a7168a786
2018-07-26 13:48:03 +02:00
Gergő Tisza
04f16a204b
Make load* methods of DifferenceEngine idempotent
These methods returned a boolean indicating whether loading the
data was successful, but then always returned true on subsequent
calls. Fix that.

This changes public methods but there's no usage in Gerrit (some
of them are called but the return value is ignored), no use case
for a caller to care, and the previous behavior has been
undocumented and unreliable, so there is no deprecation period.

Change-Id: I3998aeea66972f33274e05fa5a74d6ce7fdc56b6
2018-07-18 08:03:30 +02:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Fomafix
8b4a4b860f Deprecate string type for $lang of DifferenceEngine::setTextLanguage
Also move the comment about the default value from the setter to the
getter.

Change-Id: I2e1bd29db986dfa92d41a876340a6aa59ac6670d
Depends-On: I8b573866c2de9b21d3849f02269c1b9ca4f62aba
2018-07-02 21:25:36 +00:00
Fomafix
125cbd8c01 Use \u{00A0} instead of   or  
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or  .

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
James D. Forrester
225b462a50 Drop deprecated EnableAPI and EnableWriteAPI settings
The siteinfo API response's 'writeapi' value is now hard-set to true,
as are the ResourceLoader variables wgEnableAPI and wgEnableWriteAPI,
to be deprecated later.

Bug: T115414
Change-Id: I54ff9428b247ba203d67aba079149393f323d5a9
2018-04-18 00:30:34 +00:00
Amir Sarabadani
00a4f0939c Replace rc_patrolled values with contants, part I
This constants has been recently introduced and it's good to use them

Change-Id: I8ce56dc95de3e49610dca71c00965ca1ac74bcf0
2018-04-11 22:35:31 +02:00
Bartosz Dziewoński
99e8325cc1 DifferenceEngine: Use CSS classes instead of inline styles
Change-Id: Iee0e5e7eb73023a6f57c1f462e71cbb0e771d1f2
2018-03-05 19:24:37 +01:00