Commit graph

352 commits

Author SHA1 Message Date
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
Brad Jorsch
2791fb0861 Hard-deprecate ParserOutput stateful transform methods
This also removes all the in-core calls that had been kept for the
benefit of extensions, and causes them to not have any effect since
anything that had been calling them was already either a no-op or will
probably be broken now that nothing in core is setting or checking the
flags.

Change-Id: Id22c1a5a6d6a249debb14063ae3f8838d105b634
2018-02-13 12:28:36 -05:00
Thiemo Mättig
d77dfda69e Add missing PHPDoc block to DifferenceEngine::getParserOutput
Bug: T186163
Change-Id: Ifde6f8e458d90b1ec250dc4d587cd428717fe509
2018-02-01 12:49:57 +01:00
Brad Jorsch
e74ba29aa6 Use ParserOutput stateless transforms
We still set the state in many cases for benefit of extensions, but all
calls within core should no longer be using non-default state.

Change-Id: I78b62ec33fcb8273acb9b3b4e9012215442be94c
Depends-On: I140ff32373430b61b92226689ef9b58cca317450
2017-11-30 14:27:49 -05:00
WMDE-Fisch
9f2dde8a3a Fix regex on diff tooltips
Follow-up to I71600acc19319f7b5781b42dc88cd5e8c65c29a0

Change-Id: If307f6a02291005c12f28129a67aa00e423e5e9c
2017-11-22 11:51:43 +01:00
WMDE-Fisch
f7b1b48c4e Add localised tooltips for moved paragraph indicators
Bug: T166882
Change-Id: I71600acc19319f7b5781b42dc88cd5e8c65c29a0
2017-11-21 12:35:38 +01:00
Kunal Mehta
23ebfcddc4 DifferenceEngine: Improve cache invalidation
Invalidate the diff cache if the engine producing the diff changes, or
if a configuration setting that controls the diff output changes. This
is probably what most users expect, that changing the configuration will
result in a change for diffs that may have already been viewed.

For wikidiff2 specifically, a change in version or
$wgWikiDiff2MovedParagraphDetectionCutoff will invalidate the cache.

Refactor engine detection and sanity-checking into a private getEngine()
function.

As part of this getDiffBodyCacheKey() was deprecated, and subclasses
should implement getDiffBodyCacheKeyParams() instead. Drop the
deprecated and unused MW_DIFF_VERSION constant while we're at it, and
bump DIFF_VERSION since we're already changing the cache key format.

Bug: T180043
Change-Id: I4e386ca05bd2a2fb54208d760c131eb42e3a72ab
2017-11-21 12:10:11 +01:00
WMDE-Fisch
a656121e13 Add missing @throws in doc
Change-Id: I978369a727d557db8650b32ec155a6b490c4c866
2017-11-06 16:40:48 +01:00
Kunal Mehta
f2999fb1f7 DifferenceEngine: Add debug text for native PHP diffs
Change-Id: I004844989dfd98083f4b1f8722f6a142d47928e9
2017-11-01 23:36:11 -07:00
Kunal Mehta
66c9faccb7 DifferenceEngine: Fix wikidiff2 version check
The feature was actually released in 1.5.0.

Change-Id: Ic1a8818e34327510a75a4252f98b1f67aeeacb04
2017-11-01 11:00:22 -07:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
Umherirrender
9aa56950c2 Remove @codingStandardsIgnore from long lines
Breaks some line where the ignore is not needed.

The sniff was changed upstream to be okay
with long unbreakable lines in comments

Change-Id: I2bbe2be7cedd4d3c0ce8dc3e62d0e268bc171876
2017-10-22 16:44:04 +02:00
Max Semenik
782b207621 Switch DifferenceEngine to the new shell framework
Change-Id: Iad8718e5f54ed829efded8efbb0f3496c119e6ad
2017-10-20 16:03:04 -07:00
Brad Jorsch
7a44c51580 Fix warning in DifferenceEngine
Make sure that the ar_namespace and ar_text fields are selected from the
database.

Change-Id: Ic2e8f99f43025510c14e0a8ff2b708b378cf7ef3
2017-09-20 19:39:07 +00:00
Brad Jorsch
33ba36c88a Replace more problematic uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation.

Change-Id: I2ecb6030bf253664c3227d69b5ed2277596a83f0
2017-09-13 13:09:51 +00:00
Tobias Gritschacher
286245181d Check for Wikidiff2 version 0.3 NOT for 0.3.0
version_compare( '0.3', '0.3.0', '>=' ) gives false, so we need to check
for 0.3 since the Wikidiff2 version is defined as 0.3 in
https://gerrit.wikimedia.org/r/#/c/319866/60/Wikidiff2.h

Bug: T166571
Change-Id: Id6e9f402af2fab784a3db2444f201022e2d0de3e
2017-09-04 13:58:49 +02:00
Fomafix
6c30fab960 Use double quotes instead of singe quotes for HTML attributes
htmlspecialchars[1] encodes only double quotes not single quotes.
Therefor the HTML attribute must enclosed with double quotes for
correct output encoding.

[1] https://secure.php.net/manual/en/function.htmlspecialchars.php

Change-Id: I3fec5299585187ed70d62b9248007af34b0db85b
2017-07-26 22:56:52 +00:00
jenkins-bot
e72303c9f3 Merge "Remove auto-generated "Constructor" documentation on constructors" 2017-07-21 13:19:44 +00:00
Thiemo Mättig
91a920fd85 Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

This is similar to I994d11e. Even more trivial, because this here is
about comments that don't say anything but "constructor".

Change-Id: I474dcdb5997bea3aafd11c0760ee072dfaff124c
2017-07-21 12:19:30 +02:00
jenkins-bot
a3fc1b6236 Merge "Export revision IDs to JS config on diff pages" 2017-07-18 15:40:00 +00:00
jenkins-bot
43a548a5c3 Merge "Introduce config var for moved-paragraph-detection threshold" 2017-07-18 14:20:00 +00:00