A unique index on ar_rev_id was added in T193180 (2019), allowing
revisions of deleted pages to be reliably looked up by just their ID.
Use the improved getArchivedRevisionRecord() method in a few places
that previously had to use manual queries.
Bug: T251066
Change-Id: I9352f64952ac4b803d76e9e72f88a01be7317c56
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.
Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
Have Article opt in to inline toggle switch display, so that random
callers of DifferenceEngine::showDiffPage() do not receive a
non-functional format selector.
Bug: T342158
Change-Id: Id4e38c2a20b5381e5f70b1244304da2895eaf8e7
* Add an API-only user preference for diff type
* Retain query parameter stickiness but fix it so that the diff-type
from user preferences does not leak into the query string. So the
no-JS control continues to work. If a no-JS user has the inline
preference set, respect it on the initial load, but add an explicit
diff-type=table to the query string of the table link so that the
preference can be overridden.
* Get the diff type from the initial state of the no-JS button. Infuse
the widget to access the active property using the OOUI public API.
* For a logged-in user, when the JS toggle is clicked, fetch the new
diff body and update the user preference.
* For an anonymous user, when the JS toggle is clicked, update the
prev/next links to include the correct diff-type query parameter.
Bug: T336713
Change-Id: Ie409d79ac8222dfa6ec8fd170b76be088be80b3a
It makes sense for SlotDiffRenderer to localize the diffs that it
returns.
DifferenceEngine can't conveniently use this right now since it stores
all slot diffs concatenated together in a cache entry. It can't break
the string apart again to call the right SlotDiffRenderer on each
slot diff. So it assumes there must be a text diff in there somewhere
and calls TextDiffer over the whole thing.
EntitySchema does not have this problem and can benefit from this
method.
Bug: T342209
Change-Id: Ie06e100bb0e945de5dbe3dade14b2e6b706e078d
Since it’s needed by EntitySchema, and because it was also, as far as I
can tell, removed without following the stable interface policy in
change I5c506e3916 (commit 2aa87cdf2c).
Not marked as soft-deprecated because there doesn’t seem to be a way to
access the replacement.
Bug: T342209
Change-Id: Iba9fd8bb56ea0e1543c9a9beab85b01f9549fbd7
* Follow the TODO comment in TextSlotDiffRenderer
::getTextDiffInternal() by moving the code out to three parallel
implementations, namely ExternalTextDiffer, PhpTextDiffer and
Wikidiff2TextDiffer.
* Add a container/factory class ManifoldTextDiffer to glue them
together and collate available formats.
* Move the inline legend to Wikidiff2TextDiffer. Not the toggle since
the ability to toggle depends on the available format, not the current
format.
* Update the diff cache keys so that ManifoldTextDiffer can store the
engine=>format map it used to generate the diff.
* Drop support for the second parameter to TextSlotDiffRenderer
::setEngine(), since nothing used it anymore.
* Provide a format batch API, since some engines are able to efficiently
generate multiple formats. This might be used by DifferenceEngine in
future.
Needs risky change notification for the cache key change.
Bug: T339184
Depends-On: I8a35b9b8ec1622c9a36d2496bdd24f51bc52c85f
Change-Id: I5c506e39162855aff53dd420dd8145156739059c
StubUserLang was meant to avoid the cost of looking up the user
preferences on requests which don't need it. There's no point in using
it if you are going to unconditionally call a method on the resulting
object.
StubUserLang proxies to RequestContext::getLanguage() via __call(),
which has a cost. Originally this cost was avoided on subsequent calls
by overwriting $wgLang, but this mechanism is not effective if you retain
a reference to the StubUserLang.
Removing the potential for Title::getPageLanguage() to return
StubUserLang simplifies the type declarations for methods that call it.
Bug: T160814
Change-Id: I12ad75c2496ca727580aac55e860178d15febb6e
segmentForDiff() is supposed to allow character-level diffing of Chinese
text, by adding spaces and then removing them after the diff is
complete. But when I tested it for I2d0a6996b02d37a3, unsegmentForDiff()
failed to remove the spaces, since there was an <ins> tag between the space
and the Chinese character.
So instead, use formfeed characters to separate the Chinese characters,
and strip them unconditionally instead of relying on them being next to
Chinese characters.
Add test.
Change-Id: I230d8261bbda34ad313785a1f7c31d4db7bf989b
Fix fixme by sending the language code to SlotDiffRenderer as an option.
Note that this is the language used for word segmentation of the
content, not the UI language.
Change-Id: I2d0a6996b02d37a3f2d8fefa851244803025bb6c
And remove commented-out code also dating from 1.32 with no near-term
prospect of being implemented.
Change-Id: I526c558b2efae4b77ae38d0b5bb8127c8b31c280
Using the OOUI class name is an established pattern outside of
OOUI widgets, so it's easier to stick with it for the diff page
hiding and showing (switching to and from inline/table diffs, etc.).
Bug: T324759
Change-Id: I805b6b71d8e137eaa3e000b15455557df42af838
Links must be updated when the parser cache is updated, because
otherwise the subsequent parser cache hit on page view will suppress
further updates, breaking cascading protection.
Change-Id: I41b99e745e46329c73187c70627888651cf2d890
- Allows to reuse the RevisionRecord and not reloading in
WikiPage::getParserOutput from the RevisionStore
- Allows to pass ParserOutputAccess::OPT_NO_AUDIENCE_CHECK to get a
ParserOutput also for revision deleted content, where a check
against RevisionRecord::FOR_PUBLIC would reject the content
- Allows to show error message when render does not work
Bug: T212316
Change-Id: Id3c2de3e5cf796f5a9b213bd7bd94c9291014eb5
getTablePrefix() is used to show the inline legend and inline switcher.
It is not yet part of a released stable interface.
Theoretically there may be multiple text slots on a page, and we don't
want multiple inline legends. There was already a fragment assembly
system, for the benefit of hook handlers, so move that up to the page
level, so that it can also deduplicate prefix fragments coming from
each slot.
Add tests.
Bug: T324759
Change-Id: I9baa5c24128c63bc318ba13e83a024843f4ab15e
Add a switch that allows toggling between inline and two-column format
when Wikidiff2 is installed.
Inline toggle should also support no-JS toggling
The legend should toggle when switching from table to inline after the
first load.
Introduced a temporary feature flag to show this inline toggle so that
we can merge and easily continue the improvements. It will be removed
when ready for production.
Bug: T336712
Bug: T330229
Change-Id: Ie6a48e495f2bb299d8b984e7c40363d534c7915b
When the old and new content object for a slot cannot be compared,
show an error message for that slot only, instead of throwing an
exception.
Bug: T214217
Change-Id: I6e982df358f85ca78f0448b3a93ded3f40676310
When the old and new revisions have identical content in a given slot,
do not include the relevant SlotDiffRenderer in the return value of
DifferenceEngine::getSlotDiffRenderers(), so that the relevant table
prefixes and modules will be omitted.
Also:
* In TextSlotDiffRenderer::getTextDiff(), return an empty string when
the inputs are equal, instead of invoking the diff engine. Previously,
the inline format would produce a <tr> element in this case, causing
the diff-empty message to be omitted.
* Clarify the doc comment up the stack, indicating SlotDiffRenderer may
return zero <tr> tags, it doesn't have to be one or more.
* Fix the documented return type of getSlotContents() so that @var is
not needed in the caller.
* Don't convert the return value of SlotDiffRenderer::getDiff() to
boolean. It's always a string so compare it to the empty string.
Note that the cache key for inline empty diffs will change, because
TextSlotDiffRenderer::getExtraCacheKeys() is not called anymore for
empty diffs.
Bug: T338670
Change-Id: I0774ba0b159ac43ec214403cf2d06740f6d067cd
RangeDifference was introduced in 89f8141a7 (2008) by Guy Van den
Broeck as part of his experimental "wikidiff3" engine.
Wikidiff3 was mostly removed in dcac5f19 (2009), although the Wikidiff3
class itself remained until 20f066e97 (2016) when it was merged into
DiffEngine. The merge left diff_range() as an unused method with no
visibility modifier being the only caller of RangeDifference. "private"
was eventually added, and then finally the unused private method was
deleted, leaving no callers in core or extensions.
Change-Id: I11fd03b9b36449620518b94e2c4be02da32d1271
Also, HTML-escape the cache key in the output. In the current
implementation it is HTML-safe, but it could change.
Bug: T228761
Change-Id: I23406266fef4906cdf0a281f7058b66b30680f0d
Add a legend at the top of the inline diff display, showing the
meanings of the colours of the inserted and deleted highlighting.
Also add the same text as tooltips on the highlighted elements.
The legend is added as part of a new area above the diff table
that can be modified via a new TextSlotDiffRendererTablePrefix
hook, so that extensions can add other buttons etc. there as
required.
This is a follow-up to the previous attempt, which added the
legend in DifferenceEngine::showDiff() and was called from
too many places. This patch moves it to be called in
DifferenceEngine::showDiffPage().
Bug: T324759
Change-Id: I2a3c67bcfa47313dee597e602a62073e4e298cd2
Follow-up: I6de30bf79eb5ac262285951792782b870d075e00
To avoid showing it on other content types, such
as PageSlotDiffRenderer in ProofreadPage.
Bug: T336481
Change-Id: Ibe453fc9e8f4eea5de9c66e1446286174eb3ad17
Add a legend at the top of the inline diff display, showing the
meanings of the colours of the inserted and deleted highlighting.
Also add the same text as tooltips on the highlighted elements.
The legend is added as part of a new area above the diff table
that can be modified via a new DifferenceEngineBeforeDiffTable
hook, so that extensions can add other buttons etc. there as
required.
Bug: T324759
Change-Id: I6de30bf79eb5ac262285951792782b870d075e00