MediaWiki master
DifferenceEngine Class Reference

DifferenceEngine is responsible for rendering the difference between two revisions as HTML. More...

Inherits MediaWiki\Context\ContextSource.

Collaboration diagram for DifferenceEngine:

Public Member Functions

 __construct ( $context=null, $old=0, $new=0, $rcid=0, $refreshCache=false, $unhide=false)
 
 addHeader ( $diff, $otitle, $ntitle, $multi='', $notice='')
 Add the header to a diff body.
 
 deletedIdMarker ( $id)
 Build a wikitext link toward a deleted revision, if viewable.
 
 deletedLink ( $id)
 Look up a special:Undelete link to the given deleted revision id, as a workaround for being unable to load deleted diffs in currently.
 
 generateContentDiffBody (Content $old, Content $new)
 Generate a diff, no caching.
 
 generateTextDiffBody ( $otext, $ntext)
 Generate a diff, no caching.
 
 getDiff ( $otitle, $ntitle, $notice='')
 Get complete diff table, including header.
 
 getDiffBody ()
 Get the diff table body, without header.
 
 getDiffBodyForRole ( $role)
 Get the diff table body for one slot, without header.
 
 getDiffLang ()
 Get the language in which the diff text is written.
 
 getExtraCacheKeys ()
 Implements DifferenceEngineSlotDiffRenderer::getExtraCacheKeys().
 
 getMultiNotice ()
 If there are revisions between the ones being compared, return a note saying so.
 
 getNewid ()
 Get the ID of new revision (right pane) of the diff.
 
 getNewRevision ()
 Get the right side of the diff.
 
 getOldid ()
 Get the ID of old revision (left pane) of the diff.
 
 getOldRevision ()
 Get the left side of the diff.
 
 getPermissionErrors (Authority $performer)
 Get the permission errors associated with the revisions for the current diff.
 
 getRevisionHeader (RevisionRecord $rev, $complete='')
 Get a header for a specified revision.
 
 getRevisionLoadErrors ()
 If errors were encountered while loading the revision contents, this will return an array of Messages describing the errors.
 
 getSupportedFormats ()
 Get the list of supported text diff formats.
 
 getTextDiffFormat ()
 Get the selected text diff format.
 
 getTitle ()
 
Since
1.18
Stability: stable
to override
Returns
Title|null

 
 hasDeletedRevision ()
 Checks whether one of the given Revisions was deleted.
 
 hasSuppressedRevision ()
 Checks whether one of the given Revisions was suppressed.
 
 isUserAllowedToSeeRevisions (Authority $performer)
 Checks whether the current user has permission for accessing the revisions of the diff.
 
 loadNewText ()
 Load the text of the new revision, not the old one.
 
 loadRevisionData ()
 Load revision metadata for the specified revisions.
 
 loadText ()
 Load the text of the revisions, as well as revision data.
 
 localiseLineNumbers ( $text)
 Replace a common convention for language-independent line numbers with the text in the user's language.
 
 mapDiffPrevNext ( $old, $new)
 Maps a revision pair definition as accepted by DifferenceEngine constructor to a pair of actual integers representing revision ids.
 
 markAsSlotDiffRenderer ()
 Mark this DifferenceEngine as a slot renderer (as opposed to a page renderer).
 
 markPatrolledLink ()
 Build a link to mark a change as patrolled.
 
 renderNewRevision ()
 Show the new revision of the page.
 
 setContent (Content $oldContent, Content $newContent)
 Use specified text instead of loading from the database.
 
 setExtraQueryParams ( $params)
 Set query parameters to append to diff page links.
 
 setReducedLineNumbers ( $value=true)
 Set reduced line numbers mode.
 
 setRevisions (?RevisionRecord $oldRevision, RevisionRecord $newRevision)
 Use specified text instead of loading from the database.
 
 setSlotDiffOptions ( $options)
 
 setTextLanguage (Language $lang)
 Set the language in which the diff text is written.
 
 shouldBeHiddenFromUser (Authority $performer)
 Checks whether the diff should be hidden from the current user This is based on whether the user is allowed to see it and has specifically asked to see it.
 
 showDiff ( $otitle, $ntitle, $notice='')
 Get the diff text, send it to the OutputPage object Returns false if the diff could not be generated, otherwise returns true.
 
 showDiffPage ( $diffOnly=false)
 
 showDiffStyle ()
 Add style sheets for diff display.
 
 wasCacheHit ()
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Static Public Member Functions

static getEngine ()
 Process DiffEngine config and get a sensible, usable engine.
 
static intermediateEditsMsg ( $numEdits, $numUsers, $limit, $lastUser='[HIDDEN]')
 Get a notice about how many intermediate edits and users there are.
 

Public Attributes

bool $enableDebugComment = false
 Set this to true to add debug info to the HTML output.
 

Protected Member Functions

 debug ( $generator="internal")
 Generate a debug comment indicating diff generating time, server node, and generator backend.
 
 getDefaultLanguage ()
 Get the language to use if none has been set by setTextLanguage().
 
 getDiffBodyCacheKeyParams ()
 Get the cache key parameters.
 
 getMarkPatrolledLinkInfo ()
 Returns an array of meta data needed to build a "mark as patrolled" link and adds a JS module to the output.
 
 getSlotContents ()
 Get the old and new content objects for all slots.
 
 getSlotDiffRenderers ()
 
 getSlotError ( $errorText)
 Get an error message for inclusion in a diff body (as a table row).
 
 getSlotHeader ( $headerText)
 Get a slot header for inclusion in a diff body (as a table row).
 
 getTextDiffer ()
 Get the TextDiffer which will be used for rendering text.
 

Protected Attributes

bool $isContentOverridden = false
 Was the content overridden via setContent()? If the content was overridden, most internal state (e.g.
 
bool $isSlotDiffRenderer = false
 Temporary hack for B/C while slot diff related methods of DifferenceEngine are being deprecated.
 
LinkRenderer $linkRenderer
 
bool $mCacheHit = false
 Was the diff fetched from cache?
 
Language $mDiffLang
 
string $mMarkPatrolledLink = null
 Link to action=markpatrolled.
 
int string false null $mNewid
 Revision ID for the new revision.
 
Title null $mNewPage
 Title of new revision or null if the new revision does not exist or does not belong to a page.
 
int false null $mOldid
 Revision ID for the old revision.
 
Title null $mOldPage
 Title of old revision or null if the old revision does not exist or does not belong to a page.
 
bool $mReducedLineNumbers = false
 If true, line X is not displayed when X is 1, for example to increase readability and conserve space with many small diffs.
 
bool $mRefreshCache = false
 Refresh the diff cache.
 
bool $mRevisionsLoaded = false
 Have the revisions been loaded.
 
int $mTextLoaded = 0
 How many text blobs have been loaded, 0, 1 or 2?
 
SlotDiffRenderer[] null $slotDiffRenderers = null
 DifferenceEngine classes for the slots, keyed by role name.
 
bool $unhide = false
 Show rev_deleted content if allowed.
 

Detailed Description

DifferenceEngine is responsible for rendering the difference between two revisions as HTML.

This includes interpreting URL parameters, retrieving revision data, checking access permissions, selecting and invoking the diff generator class for the individual slots, doing post-processing on the generated diff, adding the rest of the HTML (such as headers) and writing the whole thing to OutputPage.

DifferenceEngine can be subclassed by extensions, by customizing ContentHandler::createDifferenceEngine; the content handler will be selected based on the content model of the main slot (of the new revision, when the two are different). That might change after PageTypeHandler gets introduced.

In the past, the class was also used for slot-level diff generation, and extensions might still subclass it and add such functionality. When that is the case (specifically, when a ContentHandler returns a standard SlotDiffRenderer but a nonstandard DifferenceEngine) DifferenceEngineSlotDiffRenderer will be used to convert the old behavior into the new one.

Todo:
This class is huge and poorly defined. It should be split into a controller responsible for interpreting query parameters, retrieving data and checking permissions; and a HTML renderer.

Definition at line 77 of file DifferenceEngine.php.

Constructor & Destructor Documentation

◆ __construct()

DifferenceEngine::__construct (   $context = null,
  $old = 0,
  $new = 0,
  $rcid = 0,
  $refreshCache = false,
  $unhide = false 
)
Parameters
IContextSource | null$contextContext to use, anything else will be ignored
int$oldOld ID we want to show and diff with.
string | int$newEither revision ID or 'prev' or 'next'. Default: 0.
int$rcidDeprecated, no longer used!
bool$refreshCacheIf set, refreshes the diff cache
bool$unhideIf set, allow viewing deleted revs

Definition at line 264 of file DifferenceEngine.php.

References MediaWiki\Context\ContextSource\setContext(), and wfDebug().

Member Function Documentation

◆ addHeader()

DifferenceEngine::addHeader (   $diff,
  $otitle,
  $ntitle,
  $multi = '',
  $notice = '' 
)

Add the header to a diff body.

Parameters
string$diffDiff body
string$otitleOld revision header
string$ntitleNew revision header
string$multiNotice telling user that there are intermediate revisions between the ones being compared
string$noticeOther notices, e.g. that user is viewing deleted content
Returns
string

Definition at line 1952 of file DifferenceEngine.php.

References $header.

◆ debug()

DifferenceEngine::debug (   $generator = "internal")
protected

Generate a debug comment indicating diff generating time, server node, and generator backend.

Parameters
string$generatorWhat diff engine was used
Returns
string

Definition at line 1691 of file DifferenceEngine.php.

References wfHostname(), and wfTimestamp().

◆ deletedIdMarker()

DifferenceEngine::deletedIdMarker (   $id)

Build a wikitext link toward a deleted revision, if viewable.

Parameters
int$idRevision ID
Returns
string Wikitext fragment

Definition at line 557 of file DifferenceEngine.php.

References deletedLink().

◆ deletedLink()

DifferenceEngine::deletedLink (   $id)

Look up a special:Undelete link to the given deleted revision id, as a workaround for being unable to load deleted diffs in currently.

Parameters
int$idRevision ID
Returns
string|bool Link HTML or false

Definition at line 534 of file DifferenceEngine.php.

References getAuthority().

Referenced by deletedIdMarker().

◆ generateContentDiffBody()

DifferenceEngine::generateContentDiffBody ( Content  $old,
Content  $new 
)

Generate a diff, no caching.

Since
1.21
Parameters
Content$oldOld content
Content$newNew content
Exceptions
ExceptionIf old or new content is not an instance of TextContent.
Returns
bool|string
Deprecated:
since 1.32, use a SlotDiffRenderer instead.

Definition at line 1625 of file DifferenceEngine.php.

References Content\getContentHandler(), and getContext().

◆ generateTextDiffBody()

DifferenceEngine::generateTextDiffBody (   $otext,
  $ntext 
)

Generate a diff, no caching.

Parameters
string$otextOld text, must be already segmented
string$ntextNew text, must be already segmented
Exceptions
LogicExceptionIf content handling for text content is configured in a way that makes maintaining B/C hard.
Returns
bool|string
Deprecated:
since 1.32, use a TextSlotDiffRenderer instead.

Definition at line 1653 of file DifferenceEngine.php.

References CONTENT_MODEL_TEXT, and getContext().

◆ getDefaultLanguage()

DifferenceEngine::getDefaultLanguage ( )
protected

Get the language to use if none has been set by setTextLanguage().

Wikibase overrides this to use the user language.

Returns
Language

Definition at line 471 of file DifferenceEngine.php.

References getTitle().

Referenced by getDiffLang().

◆ getDiff()

DifferenceEngine::getDiff (   $otitle,
  $ntitle,
  $notice = '' 
)

Get complete diff table, including header.

Parameters
string | false$otitleHeader for old text or false
string | false$ntitleHeader for new text or false
string$noticeHTML between diff header and body
Returns
string|false

Definition at line 1327 of file DifferenceEngine.php.

◆ getDiffBody()

DifferenceEngine::getDiffBody ( )

Get the diff table body, without header.

Returns
string|false

Definition at line 1353 of file DifferenceEngine.php.

References LocalizedException\getMessageObject().

◆ getDiffBodyCacheKeyParams()

DifferenceEngine::getDiffBodyCacheKeyParams ( )
protected

Get the cache key parameters.

Subclasses can replace the first element in the array to something more specific to the type of diff (e.g. "inline-diff"), or append if the cache should vary on more things. Overriding entirely should be avoided.

Since
1.31
Returns
string[]

Definition at line 1521 of file DifferenceEngine.php.

References $params.

Referenced by getExtraCacheKeys().

◆ getDiffBodyForRole()

DifferenceEngine::getDiffBodyForRole (   $role)

Get the diff table body for one slot, without header.

Parameters
string$role
Returns
string|false

Definition at line 1453 of file DifferenceEngine.php.

References LocalizedException\getMessageObject().

◆ getDiffLang()

DifferenceEngine::getDiffLang ( )

Get the language in which the diff text is written.

Returns
Language

Definition at line 459 of file DifferenceEngine.php.

References getDefaultLanguage().

Referenced by getSlotDiffRenderers().

◆ getEngine()

static DifferenceEngine::getEngine ( )
static

Process DiffEngine config and get a sensible, usable engine.

Returns
string 'wikidiff2', 'php', or path to an executable
Access: internal
For use by this class and within Core only.

Definition at line 1672 of file DifferenceEngine.php.

◆ getExtraCacheKeys()

DifferenceEngine::getExtraCacheKeys ( )

Implements DifferenceEngineSlotDiffRenderer::getExtraCacheKeys().

Only used when DifferenceEngine is wrapped in DifferenceEngineSlotDiffRenderer.

Returns
string[]
Access: internal
for use by DifferenceEngineSlotDiffRenderer only
Deprecated:

Definition at line 1550 of file DifferenceEngine.php.

References $params, and getDiffBodyCacheKeyParams().

◆ getMarkPatrolledLinkInfo()

DifferenceEngine::getMarkPatrolledLinkInfo ( )
protected

Returns an array of meta data needed to build a "mark as patrolled" link and adds a JS module to the output.

Returns
array|false An array of meta data for a patrol link (rcid only) or false if no link is needed

Definition at line 1106 of file DifferenceEngine.php.

References getAuthority(), and getUser().

◆ getMultiNotice()

DifferenceEngine::getMultiNotice ( )

If there are revisions between the ones being compared, return a note saying so.

Returns
string

Definition at line 1753 of file DifferenceEngine.php.

References getAuthority().

◆ getNewid()

DifferenceEngine::getNewid ( )

Get the ID of new revision (right pane) of the diff.

0 for the current revision, false if the new revision does not exist, null if it's unsaved. To get a real revision ID instead of 0, call loadRevisionData() first.

Returns
int|false|null

Definition at line 501 of file DifferenceEngine.php.

◆ getNewRevision()

DifferenceEngine::getNewRevision ( )

Get the right side of the diff.

Should not be null but can still happen in the case of load failure.

Returns
RevisionRecord|null

Definition at line 522 of file DifferenceEngine.php.

◆ getOldid()

DifferenceEngine::getOldid ( )

Get the ID of old revision (left pane) of the diff.

0 for the revision previous to getNewid(), false if the old revision does not exist, null if it's unsaved. To get a real revision ID instead of 0, call loadRevisionData() first.

Returns
int|false|null

Definition at line 489 of file DifferenceEngine.php.

◆ getOldRevision()

DifferenceEngine::getOldRevision ( )

Get the left side of the diff.

Could be null when the first revision of the page is diffed to 'prev' (or in the case of load failure).

Returns
RevisionRecord|null

Definition at line 513 of file DifferenceEngine.php.

◆ getPermissionErrors()

DifferenceEngine::getPermissionErrors ( Authority  $performer)

Get the permission errors associated with the revisions for the current diff.

Parameters
Authority$performer
Returns
array[] Array of arrays of the arguments to wfMessage to explain permissions problems.

Definition at line 608 of file DifferenceEngine.php.

References MediaWiki\Permissions\Authority\authorizeRead(), and loadRevisionData().

◆ getRevisionHeader()

DifferenceEngine::getRevisionHeader ( RevisionRecord  $rev,
  $complete = '' 
)

Get a header for a specified revision.

Parameters
RevisionRecord$rev
string$complete'complete' to get the header wrapped depending the visibility of the revision and a link to edit the page.
Returns
string HTML fragment

Definition at line 1876 of file DifferenceEngine.php.

References $header, getAuthority(), MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getPage(), MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget(), MediaWiki\Revision\RevisionRecord\getTimestamp(), getUser(), MediaWiki\Revision\RevisionRecord\isCurrent(), MediaWiki\Revision\RevisionRecord\isDeleted(), and wfTimestamp().

◆ getRevisionLoadErrors()

DifferenceEngine::getRevisionLoadErrors ( )

If errors were encountered while loading the revision contents, this will return an array of Messages describing the errors.

Returns
Message[]

Definition at line 421 of file DifferenceEngine.php.

◆ getSlotContents()

DifferenceEngine::getSlotContents ( )
protected

Get the old and new content objects for all slots.

This method does not do any permission checks.

Returns
(Content|null)[][] [ role => [ 'old' => Content|null, 'new' => Content|null ], ... ]

Definition at line 346 of file DifferenceEngine.php.

References loadRevisionData().

Referenced by getSlotDiffRenderers().

◆ getSlotDiffRenderers()

DifferenceEngine::getSlotDiffRenderers ( )
protected
Returns
SlotDiffRenderer[] Diff renderers for each slot, keyed by role name. Includes slots only present in one of the revisions. Does not include slots for which content is identical in the two revisions.

Definition at line 298 of file DifferenceEngine.php.

References getContext(), getDiffLang(), getSlotContents(), getTextDiffer(), and loadRevisionData().

◆ getSlotError()

DifferenceEngine::getSlotError (   $errorText)
protected

Get an error message for inclusion in a diff body (as a table row).

Parameters
string$errorTextThe HTML of the error
Returns
string

Definition at line 1500 of file DifferenceEngine.php.

◆ getSlotHeader()

DifferenceEngine::getSlotHeader (   $headerText)
protected

Get a slot header for inclusion in a diff body (as a table row).

Parameters
string$headerTextThe text of the header
Returns
string

Definition at line 1486 of file DifferenceEngine.php.

◆ getSupportedFormats()

DifferenceEngine::getSupportedFormats ( )

Get the list of supported text diff formats.

Since
1.41
Returns
array|string[]

Definition at line 2354 of file DifferenceEngine.php.

◆ getTextDiffer()

DifferenceEngine::getTextDiffer ( )
protected

Get the TextDiffer which will be used for rendering text.

Returns
ManifoldTextDiffer

Definition at line 2335 of file DifferenceEngine.php.

References getContext().

Referenced by getSlotDiffRenderers().

◆ getTextDiffFormat()

DifferenceEngine::getTextDiffFormat ( )

Get the selected text diff format.

Since
1.41
Returns
string

Definition at line 2364 of file DifferenceEngine.php.

◆ getTitle()

DifferenceEngine::getTitle ( )

Since
1.18
Stability: stable
to override
Returns
Title|null

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 439 of file DifferenceEngine.php.

References NS_SPECIAL.

◆ hasDeletedRevision()

DifferenceEngine::hasDeletedRevision ( )

Checks whether one of the given Revisions was deleted.

Returns
bool

Definition at line 590 of file DifferenceEngine.php.

References loadRevisionData().

Referenced by hasSuppressedRevision().

◆ hasSuppressedRevision()

DifferenceEngine::hasSuppressedRevision ( )

Checks whether one of the given Revisions was suppressed.

Returns
bool

Definition at line 625 of file DifferenceEngine.php.

References hasDeletedRevision().

◆ intermediateEditsMsg()

static DifferenceEngine::intermediateEditsMsg (   $numEdits,
  $numUsers,
  $limit,
  $lastUser = '[HIDDEN]' 
)
static

Get a notice about how many intermediate edits and users there are.

Parameters
int$numEdits
int$numUsers
int$limit
string$lastUser
Returns
string

Definition at line 1838 of file DifferenceEngine.php.

References wfMessage().

◆ isUserAllowedToSeeRevisions()

DifferenceEngine::isUserAllowedToSeeRevisions ( Authority  $performer)

Checks whether the current user has permission for accessing the revisions of the diff.

Note that this does not check whether the user has permission to view the page, it only checks revdelete permissions.

It is the caller's responsibility to call $this->getUserPermissionErrors or similar checks.

Parameters
Authority$performer
Returns
bool

Definition at line 702 of file DifferenceEngine.php.

◆ loadNewText()

DifferenceEngine::loadNewText ( )

Load the text of the new revision, not the old one.

Returns
bool Whether the content of the new revision could be loaded successfully.

Definition at line 2308 of file DifferenceEngine.php.

References getAuthority().

◆ loadRevisionData()

DifferenceEngine::loadRevisionData ( )

Load revision metadata for the specified revisions.

If newid is 0, then compare the old revision in oldid to the current revision of the current page (as defined by the request context); if oldid is 0, then compare the revision in newid to the immediately previous one.

If oldid is false, leave the corresponding RevisionRecord object set to false. This can happen with 'diff=prev' pointing to a non-existent revision, and is also used directly by the API.

Returns
bool Whether both revisions were loaded successfully. Setting mOldRevisionRecord to false counts as successful loading.

Definition at line 2166 of file DifferenceEngine.php.

References MediaWiki\Revision\RevisionRecord\getId(), and getTitle().

Referenced by getPermissionErrors(), getSlotContents(), getSlotDiffRenderers(), and hasDeletedRevision().

◆ loadText()

DifferenceEngine::loadText ( )

Load the text of the revisions, as well as revision data.

When the old revision is missing (mOldRev is false), loading mOldContent is not attempted.

Returns
bool Whether the content of both revisions could be loaded successfully. (When mOldRev is false, that still counts as a success.)

Definition at line 2265 of file DifferenceEngine.php.

References getAuthority().

◆ localiseLineNumbers()

DifferenceEngine::localiseLineNumbers (   $text)

Replace a common convention for language-independent line numbers with the text in the user's language.

Deprecated:
since 1.41, use BaseTextDiffer::localizeLineNumbers()
Parameters
string$text
Returns
string

Definition at line 1738 of file DifferenceEngine.php.

References $matches.

◆ mapDiffPrevNext()

DifferenceEngine::mapDiffPrevNext (   $old,
  $new 
)

Maps a revision pair definition as accepted by DifferenceEngine constructor to a pair of actual integers representing revision ids.

Parameters
int$oldRevision id, e.g. from URL parameter 'oldid'
int | string$newRevision id or strings 'next' or 'prev', e.g. from URL parameter 'diff'
Returns
array List of two revision ids, older first, later second. Zero signifies invalid argument passed. false signifies that there is no previous/next revision ($old is the oldest/newest one).

Definition at line 2099 of file DifferenceEngine.php.

◆ markAsSlotDiffRenderer()

DifferenceEngine::markAsSlotDiffRenderer ( )

Mark this DifferenceEngine as a slot renderer (as opposed to a page renderer).

This is used in legacy mode when the DifferenceEngine is wrapped in a DifferenceEngineSlotDiffRenderer.

Access: internal
For use by DifferenceEngineSlotDiffRenderer only.

Definition at line 337 of file DifferenceEngine.php.

◆ markPatrolledLink()

DifferenceEngine::markPatrolledLink ( )

Build a link to mark a change as patrolled.

Returns empty string if there's either no revision to patrol or the user is not allowed to.

Side effect: When the patrol link is build, this method will call OutputPage::setPreventClickjacking(true) and load a JS module.

Returns
string HTML or empty string

Definition at line 1073 of file DifferenceEngine.php.

◆ renderNewRevision()

DifferenceEngine::renderNewRevision ( )

Show the new revision of the page.

Note
Not supported after calling setContent().

Definition at line 1181 of file DifferenceEngine.php.

References getContext(), and getTitle().

◆ setContent()

DifferenceEngine::setContent ( Content  $oldContent,
Content  $newContent 
)

Use specified text instead of loading from the database.

Parameters
Content$oldContent
Content$newContent
Since
1.21
Deprecated:
since 1.32, use setRevisions or ContentHandler::getSlotDiffRenderer.

Definition at line 2029 of file DifferenceEngine.php.

Referenced by DifferenceEngineSlotDiffRenderer\__construct().

◆ setExtraQueryParams()

DifferenceEngine::setExtraQueryParams (   $params)

Set query parameters to append to diff page links.

Since
1.41
Parameters
array$params

Definition at line 1608 of file DifferenceEngine.php.

References $params.

◆ setReducedLineNumbers()

DifferenceEngine::setReducedLineNumbers (   $value = true)

Set reduced line numbers mode.

When set, line X is not displayed when X is 1, for example to increase readability and conserve space with many small diffs.

Parameters
bool$value

Definition at line 450 of file DifferenceEngine.php.

◆ setRevisions()

DifferenceEngine::setRevisions ( ?RevisionRecord  $oldRevision,
RevisionRecord  $newRevision 
)

Use specified text instead of loading from the database.

Parameters
RevisionRecord | null$oldRevision
RevisionRecord$newRevision

Definition at line 2044 of file DifferenceEngine.php.

References getAuthority(), MediaWiki\Revision\RevisionRecord\getContent(), MediaWiki\Revision\RevisionRecord\getId(), and MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget().

◆ setSlotDiffOptions()

DifferenceEngine::setSlotDiffOptions (   $options)
Parameters
array$optionsfor the difference engine. Available options:
  • diff-type: The text diff format, e.g. "table" or "inline". If the specified format is not supported, the option will be ignored, so the site default format (table) will be used.
  • expand-url: If true, put full URLs in href attributes (for action=render) FIXME: expand-url is not a slot diff option, it is a DifferenceEngine option.
  • inline-toggle: If true, and the inline format is supported a format selector toggle switch will be shown.

Definition at line 1585 of file DifferenceEngine.php.

◆ setTextLanguage()

DifferenceEngine::setTextLanguage ( Language  $lang)

Set the language in which the diff text is written.

Parameters
Language$lang
Since
1.19

Definition at line 2083 of file DifferenceEngine.php.

◆ shouldBeHiddenFromUser()

DifferenceEngine::shouldBeHiddenFromUser ( Authority  $performer)

Checks whether the diff should be hidden from the current user This is based on whether the user is allowed to see it and has specifically asked to see it.

Parameters
Authority$performer
Returns
bool

Definition at line 727 of file DifferenceEngine.php.

◆ showDiff()

DifferenceEngine::showDiff (   $otitle,
  $ntitle,
  $notice = '' 
)

Get the diff text, send it to the OutputPage object Returns false if the diff could not be generated, otherwise returns true.

Parameters
string | false$otitleHeader for old text or false
string | false$ntitleHeader for new text or false
string$noticeHTML between diff header and body
Returns
bool

Definition at line 1284 of file DifferenceEngine.php.

◆ showDiffPage()

DifferenceEngine::showDiffPage (   $diffOnly = false)
Parameters
bool$diffOnly

Definition at line 735 of file DifferenceEngine.php.

References ChangeTags\formatSummaryRow(), getAuthority(), getContext(), getRequest(), getTitle(), and getUser().

◆ showDiffStyle()

DifferenceEngine::showDiffStyle ( )

Add style sheets for diff display.

Definition at line 1305 of file DifferenceEngine.php.

◆ wasCacheHit()

DifferenceEngine::wasCacheHit ( )
Returns
bool

Definition at line 478 of file DifferenceEngine.php.

Member Data Documentation

◆ $enableDebugComment

bool DifferenceEngine::$enableDebugComment = false

Set this to true to add debug info to the HTML output.

Warning: this may cause RSS readers to spuriously mark articles as "new" (T22601)

Definition at line 199 of file DifferenceEngine.php.

◆ $isContentOverridden

bool DifferenceEngine::$isContentOverridden = false
protected

Was the content overridden via setContent()? If the content was overridden, most internal state (e.g.

mOldid or mOldRev) should be ignored and only mOldContent and mNewContent is reliable. (Note that setRevisions() does not set this flag as in that case all properties are overridden and remain consistent with each other, so no special handling is needed.)

Definition at line 185 of file DifferenceEngine.php.

◆ $isSlotDiffRenderer

bool DifferenceEngine::$isSlotDiffRenderer = false
protected

Temporary hack for B/C while slot diff related methods of DifferenceEngine are being deprecated.

When true, we are inside a DifferenceEngineSlotDiffRenderer and $slotDiffRenderers should not be used.

Definition at line 224 of file DifferenceEngine.php.

◆ $linkRenderer

LinkRenderer DifferenceEngine::$linkRenderer
protected

Definition at line 240 of file DifferenceEngine.php.

◆ $mCacheHit

bool DifferenceEngine::$mCacheHit = false
protected

Was the diff fetched from cache?

Definition at line 188 of file DifferenceEngine.php.

◆ $mDiffLang

Language DifferenceEngine::$mDiffLang
protected

Definition at line 166 of file DifferenceEngine.php.

◆ $mMarkPatrolledLink

string DifferenceEngine::$mMarkPatrolledLink = null
protected

Link to action=markpatrolled.

Definition at line 207 of file DifferenceEngine.php.

◆ $mNewid

int string false null DifferenceEngine::$mNewid
protected

Revision ID for the new revision.

0 for the last revision of the current page (as defined by the request context), false if the revision does not exist, null if it is unsaved, or an alias such as 'next'.

Definition at line 103 of file DifferenceEngine.php.

◆ $mNewPage

Title null DifferenceEngine::$mNewPage
protected

Title of new revision or null if the new revision does not exist or does not belong to a page.

Definition at line 137 of file DifferenceEngine.php.

◆ $mOldid

int false null DifferenceEngine::$mOldid
protected

Revision ID for the old revision.

0 for the revision previous to $mNewid, false if the diff does not have an old revision (e.g. 'oldid=<first revision of page>&diff=prev'), or the revision does not exist, null if the revision is unsaved.

Definition at line 95 of file DifferenceEngine.php.

◆ $mOldPage

Title null DifferenceEngine::$mOldPage
protected

Title of old revision or null if the old revision does not exist or does not belong to a page.

Definition at line 131 of file DifferenceEngine.php.

◆ $mReducedLineNumbers

bool DifferenceEngine::$mReducedLineNumbers = false
protected

If true, line X is not displayed when X is 1, for example to increase readability and conserve space with many small diffs.

Definition at line 204 of file DifferenceEngine.php.

◆ $mRefreshCache

bool DifferenceEngine::$mRefreshCache = false
protected

Refresh the diff cache.

Definition at line 213 of file DifferenceEngine.php.

◆ $mRevisionsLoaded

bool DifferenceEngine::$mRevisionsLoaded = false
protected

Have the revisions been loaded.

Definition at line 172 of file DifferenceEngine.php.

◆ $mTextLoaded

int DifferenceEngine::$mTextLoaded = 0
protected

How many text blobs have been loaded, 0, 1 or 2?

Definition at line 175 of file DifferenceEngine.php.

◆ $slotDiffRenderers

SlotDiffRenderer [] null DifferenceEngine::$slotDiffRenderers = null
protected

DifferenceEngine classes for the slots, keyed by role name.

Definition at line 216 of file DifferenceEngine.php.

◆ $unhide

bool DifferenceEngine::$unhide = false
protected

Show rev_deleted content if allowed.

Definition at line 210 of file DifferenceEngine.php.


The documentation for this class was generated from the following file: