MediaWiki REL1_37
|
DifferenceEngine is responsible for rendering the difference between two revisions as HTML. More...
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 of the difference engine, defaults to page content language. | |
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. | |
getTitle () | |
| |
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 line numbers with the text in the user's language. | |
localiseLineNumbersCb ( $matches) | |
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. | |
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 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. | |
getAuthority () | |
getConfig () | |
getContext () | |
Get the base IContextSource object. | |
getCsrfTokenSet () | |
Get a repository to obtain and match CSRF tokens. | |
getLanguage () | |
getOutput () | |
getRequest () | |
getSkin () | |
getStats () | |
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 sane, usable engine. | |
static | intermediateEditsMsg ( $numEdits, $numUsers, $limit) |
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. | |
getDiffBodyCacheKey () | |
Returns the cache key for diff body text or content. | |
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. | |
getParserOutput (WikiPage $page, RevisionRecord $revRecord) | |
getSlotContents () | |
Get the old and new content objects for all slots. | |
getSlotDiffRenderers () | |
getSlotHeader ( $headerText) | |
Get a slot header for inclusion in a diff body (as a table row). | |
textDiff ( $otext, $ntext) | |
Generates diff, to be wrapped internally in a logging/instrumentation. | |
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[] | $slotDiffRenderers = null |
DifferenceEngine classes for the slots, keyed by role name. | |
bool | $unhide = false |
Show rev_deleted content if allowed. | |
Private Member Functions | |
addLocalisedTitleTooltips ( $text) | |
Add title attributes for tooltips on moved paragraph indicators. | |
addLocalisedTitleTooltipsCb (array $matches) | |
getDebugString () | |
loadRevisionIds () | |
localiseDiff ( $text) | |
Localise diff output. | |
revisionDeleteLink (RevisionRecord $revRecord) | |
showMissingRevision () | |
userCanEdit (RevisionRecord $revRecord) | |
Private Attributes | |
IContentHandlerFactory | $contentHandlerFactory |
HookRunner | $hookRunner |
Content null | $mNewContent |
RevisionRecord null | $mNewRevisionRecord |
New revision (right pane). | |
string[] null | $mNewTags |
Change tags of new revision or null if it does not exist / is not saved. | |
Content null | $mOldContent |
RevisionRecord null false | $mOldRevisionRecord |
Old revision (left pane). | |
string[] null | $mOldTags |
Change tags of old revision or null if it does not exist / is not saved. | |
bool | $mRevisionsIdsLoaded = false |
Have the revisions IDs been loaded. | |
RevisionStore | $revisionStore |
array | $slotDiffOptions = [] |
A set of options that will be passed to the SlotDiffRenderer upon creation. | |
WikiPageFactory | $wikiPageFactory |
const | DIFF_VERSION = '1.12' |
Constant to indicate diff cache compatibility. | |
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 (sepcifically, when a ContentHandler returns a standard SlotDiffRenderer but a nonstandard DifferenceEngine) DifferenceEngineSlotDiffRenderer will be used to convert the old behavior into the new one.
Definition at line 58 of file DifferenceEngine.php.
DifferenceEngine::__construct | ( | $context = null , |
|
$old = 0 , |
|||
$new = 0 , |
|||
$rcid = 0 , |
|||
$refreshCache = false , |
|||
$unhide = false |
|||
) |
#-
IContextSource | null | $context | Context to use, anything else will be ignored |
int | $old | Old ID we want to show and diff with. |
string | int | $new | Either revision ID or 'prev' or 'next'. Default: 0. |
int | $rcid | Deprecated, no longer used! |
bool | $refreshCache | If set, refreshes the diff cache |
bool | $unhide | If set, allow viewing deleted revs |
Definition at line 243 of file DifferenceEngine.php.
References ContextSource\$context, deprecatePublicProperty(), ContextSource\setContext(), and wfDebug().
DifferenceEngine::addHeader | ( | $diff, | |
$otitle, | |||
$ntitle, | |||
$multi = '' , |
|||
$notice = '' |
|||
) |
Add the header to a diff body.
string | $diff | Diff body |
string | $otitle | Old revision header |
string | $ntitle | New revision header |
string | $multi | Notice telling user that there are intermediate revisions between the ones being compared |
string | $notice | Other notices, e.g. that user is viewing deleted content |
Definition at line 1792 of file DifferenceEngine.php.
References $header, getDiffLang(), ContextSource\getLanguage(), and ContextSource\getUser().
Referenced by getDiff(), and showDiffPage().
|
private |
Add title attributes for tooltips on moved paragraph indicators.
string | $text |
Definition at line 1602 of file DifferenceEngine.php.
Referenced by localiseDiff().
|
private |
array | $matches |
Definition at line 1614 of file DifferenceEngine.php.
References $matches, and ContextSource\msg().
|
protected |
Generate a debug comment indicating diff generating time, server node, and generator backend.
string | $generator | : What diff engine was used |
Definition at line 1524 of file DifferenceEngine.php.
References $generator, ContextSource\getConfig(), wfHostname(), and wfTimestamp().
Referenced by getDebugString().
DifferenceEngine::deletedIdMarker | ( | $id | ) |
Build a wikitext link toward a deleted revision, if viewable.
int | $id | Revision ID |
Definition at line 480 of file DifferenceEngine.php.
References deletedLink().
Referenced by showMissingRevision().
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.
int | $id | Revision ID |
Definition at line 446 of file DifferenceEngine.php.
References $dbr, $revStore, $title, DB_REPLICA, getAuthority(), SpecialPage\getTitleFor(), and wfGetDB().
Referenced by deletedIdMarker().
Generate a diff, no caching.
Exception | If old or new content is not an instance of TextContent. |
Definition at line 1394 of file DifferenceEngine.php.
References Content\getContentHandler(), getContext(), and getDebugString().
DifferenceEngine::generateTextDiffBody | ( | $otext, | |
$ntext | |||
) |
Generate a diff, no caching.
string | $otext | Old text, must be already segmented |
string | $ntext | New text, must be already segmented |
Exception | If content handling for text content is configured in a way that makes maintaining B/C hard. |
Definition at line 1422 of file DifferenceEngine.php.
References CONTENT_MODEL_TEXT, getContext(), and getDebugString().
|
private |
Definition at line 1542 of file DifferenceEngine.php.
References debug().
Referenced by generateContentDiffBody(), generateTextDiffBody(), and textDiff().
DifferenceEngine::getDiff | ( | $otitle, | |
$ntitle, | |||
$notice = '' |
|||
) |
Get complete diff table, including header.
string | false | $otitle | Header for old text or false |
string | false | $ntitle | Header for new text or false |
string | $notice | HTML between diff header and body |
Definition at line 1124 of file DifferenceEngine.php.
References addHeader(), getDiffBody(), getMultiNotice(), and ContextSource\msg().
Referenced by showDiff().
DifferenceEngine::getDiffBody | ( | ) |
Get the diff table body, without header.
Definition at line 1146 of file DifferenceEngine.php.
References $cache, getDiffBodyCacheKey(), getDiffBodyCacheKeyParams(), getSlotContents(), getSlotDiffRenderers(), getSlotHeader(), loadRevisionData(), loadText(), and localiseDiff().
Referenced by getDiff().
|
protected |
Returns the cache key for diff body text or content.
MWException |
Definition at line 1293 of file DifferenceEngine.php.
Referenced by getDiffBody(), and getExtraCacheKeys().
|
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.
MWException |
Definition at line 1310 of file DifferenceEngine.php.
References getEngine(), and getSlotDiffRenderers().
Referenced by getDiffBody(), and getExtraCacheKeys().
DifferenceEngine::getDiffBodyForRole | ( | $role | ) |
Get the diff table body for one slot, without header.
string | $role |
Definition at line 1247 of file DifferenceEngine.php.
References getSlotContents(), getSlotDiffRenderers(), getSlotHeader(), and localiseDiff().
DifferenceEngine::getDiffLang | ( | ) |
Get the language of the difference engine, defaults to page content language.
Definition at line 378 of file DifferenceEngine.php.
References getTitle().
Referenced by addHeader().
|
static |
Process DiffEngine config and get a sane, usable engine.
Definition at line 1441 of file DifferenceEngine.php.
References wfDebug(), and wfWarn().
Referenced by getDiffBodyCacheKeyParams(), and localiseDiff().
DifferenceEngine::getExtraCacheKeys | ( | ) |
Implements DifferenceEngineSlotDiffRenderer::getExtraCacheKeys().
Only used when DifferenceEngine is wrapped in DifferenceEngineSlotDiffRenderer.
Definition at line 1344 of file DifferenceEngine.php.
References getDiffBodyCacheKey(), and getDiffBodyCacheKeyParams().
|
protected |
Returns an array of meta data needed to build a "mark as patrolled" link and adds a JS module to the output.
Definition at line 901 of file DifferenceEngine.php.
References getAuthority(), ContextSource\getConfig(), ContextSource\getOutput(), and ContextSource\getUser().
Referenced by markPatrolledLink().
DifferenceEngine::getMultiNotice | ( | ) |
If there are revisions between the ones being compared, return a note saying so.
Definition at line 1626 of file DifferenceEngine.php.
Referenced by getDiff(), and showDiffPage().
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.
Definition at line 413 of file DifferenceEngine.php.
References loadRevisionIds().
DifferenceEngine::getNewRevision | ( | ) |
Get the right side of the diff.
Should not be null but can still happen in the case of load failure.
Definition at line 434 of file DifferenceEngine.php.
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.
Definition at line 401 of file DifferenceEngine.php.
References loadRevisionIds().
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).
Definition at line 425 of file DifferenceEngine.php.
|
protected |
WikiPage | $page | |
RevisionRecord | $revRecord |
Definition at line 1058 of file DifferenceEngine.php.
References getContext(), MediaWiki\Revision\RevisionRecord\getId(), WikiPage\getParserOutput(), and WikiPage\makeParserOptions().
Referenced by renderNewRevision().
DifferenceEngine::getPermissionErrors | ( | Authority | $performer | ) |
Get the permission errors associated with the revisions for the current diff.
Authority | $performer |
Definition at line 535 of file DifferenceEngine.php.
References MediaWiki\Permissions\Authority\authorizeRead(), and loadRevisionData().
Referenced by showDiffPage().
DifferenceEngine::getRevisionHeader | ( | RevisionRecord | $rev, |
$complete = '' |
|||
) |
Get a header for a specified revision.
RevisionRecord | $rev | |
string | $complete | 'complete' to get the header wrapped depending the visibility of the revision and a link to edit the page. |
Definition at line 1727 of file DifferenceEngine.php.
References $header, $lang, $title, getAuthority(), MediaWiki\Revision\RevisionRecord\getId(), ContextSource\getLanguage(), MediaWiki\Revision\RevisionRecord\getPage(), MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget(), Linker\getRevisionDeletedClass(), MediaWiki\Revision\RevisionRecord\getTimestamp(), ContextSource\getUser(), MediaWiki\Revision\RevisionRecord\isCurrent(), MediaWiki\Revision\RevisionRecord\isDeleted(), ContextSource\msg(), and userCanEdit().
Referenced by renderNewRevision(), and showDiffPage().
|
protected |
Get the old and new content objects for all slots.
This method does not do any permission checks.
Definition at line 319 of file DifferenceEngine.php.
References loadRevisionData().
Referenced by getDiffBody(), getDiffBodyForRole(), and getSlotDiffRenderers().
|
protected |
Definition at line 279 of file DifferenceEngine.php.
References $content, ContextSource\$context, getContext(), getSlotContents(), and loadRevisionData().
Referenced by getDiffBody(), getDiffBodyCacheKeyParams(), getDiffBodyForRole(), and showDiffStyle().
|
protected |
Get a slot header for inclusion in a diff body (as a table row).
string | $headerText | The text of the header |
Definition at line 1276 of file DifferenceEngine.php.
References ContextSource\getLanguage().
Referenced by getDiffBody(), and getDiffBodyForRole().
DifferenceEngine::getTitle | ( | ) |
Reimplemented from ContextSource.
Definition at line 358 of file DifferenceEngine.php.
References NS_SPECIAL.
DifferenceEngine::hasDeletedRevision | ( | ) |
Checks whether one of the given Revisions was deleted.
Definition at line 517 of file DifferenceEngine.php.
References loadRevisionData().
Referenced by hasSuppressedRevision(), shouldBeHiddenFromUser(), and showDiffPage().
DifferenceEngine::hasSuppressedRevision | ( | ) |
Checks whether one of the given Revisions was suppressed.
Definition at line 552 of file DifferenceEngine.php.
References hasDeletedRevision().
Referenced by showDiffPage().
|
static |
Get a notice about how many intermediate edits and users there are.
int | $numEdits | |
int | $numUsers | |
int | $limit |
Definition at line 1693 of file DifferenceEngine.php.
References wfMessage().
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.
Authority | $performer |
Definition at line 572 of file DifferenceEngine.php.
References loadRevisionData().
Referenced by shouldBeHiddenFromUser(), and showDiffPage().
DifferenceEngine::loadNewText | ( | ) |
Load the text of the new revision, not the old one.
Definition at line 2137 of file DifferenceEngine.php.
References getAuthority(), and loadRevisionData().
Referenced by renderNewRevision().
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.
Definition at line 1984 of file DifferenceEngine.php.
References $dbr, DB_REPLICA, getTitle(), loadRevisionIds(), and wfGetDB().
Referenced by getDiffBody(), getPermissionErrors(), getSlotContents(), getSlotDiffRenderers(), hasDeletedRevision(), isUserAllowedToSeeRevisions(), loadNewText(), loadText(), and showDiffPage().
|
private |
Definition at line 1950 of file DifferenceEngine.php.
References getTitle().
Referenced by getNewid(), getOldid(), and loadRevisionData().
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.
Definition at line 2094 of file DifferenceEngine.php.
References getAuthority(), and loadRevisionData().
Referenced by getDiffBody().
|
private |
Localise diff output.
string | $text |
Definition at line 1559 of file DifferenceEngine.php.
References addLocalisedTitleTooltips(), getEngine(), and localiseLineNumbers().
Referenced by getDiffBody(), and getDiffBodyForRole().
DifferenceEngine::localiseLineNumbers | ( | $text | ) |
Replace line numbers with the text in the user's language.
string | $text |
Definition at line 1576 of file DifferenceEngine.php.
Referenced by localiseDiff().
DifferenceEngine::localiseLineNumbersCb | ( | $matches | ) |
array | $matches |
Definition at line 1588 of file DifferenceEngine.php.
References $matches, and ContextSource\msg().
DifferenceEngine::mapDiffPrevNext | ( | $old, | |
$new | |||
) |
Maps a revision pair definition as accepted by DifferenceEngine constructor to a pair of actual integers representing revision ids.
int | $old | Revision id, e.g. from URL parameter 'oldid' |
int | string | $new | Revision id or strings 'next' or 'prev', e.g. from URL parameter 'diff' |
Definition at line 1919 of file DifferenceEngine.php.
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.
Definition at line 310 of file DifferenceEngine.php.
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::preventClickjacking() and load a JS module.
Definition at line 869 of file DifferenceEngine.php.
References getMarkPatrolledLinkInfo(), and ContextSource\msg().
Referenced by renderNewRevision(), and showDiffPage().
DifferenceEngine::renderNewRevision | ( | ) |
Show the new revision of the page.
Definition at line 978 of file DifferenceEngine.php.
References ContextSource\getOutput(), getParserOutput(), getRevisionHeader(), getTitle(), ContextSource\getWikiPage(), loadNewText(), and markPatrolledLink().
Referenced by showDiffPage().
|
private |
RevisionRecord | $revRecord |
Definition at line 960 of file DifferenceEngine.php.
References getAuthority(), MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget(), and Linker\getRevDeleteLink().
Referenced by showDiffPage().
Use specified text instead of loading from the database.
Definition at line 1855 of file DifferenceEngine.php.
Referenced by DifferenceEngineSlotDiffRenderer\__construct().
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.
bool | $value |
Definition at line 369 of file DifferenceEngine.php.
DifferenceEngine::setRevisions | ( | ?RevisionRecord | $oldRevision, |
RevisionRecord | $newRevision | ||
) |
Use specified text instead of loading from the database.
RevisionRecord | null | $oldRevision | |
RevisionRecord | $newRevision |
Definition at line 1870 of file DifferenceEngine.php.
References getAuthority(), MediaWiki\Revision\RevisionRecord\getContent(), MediaWiki\Revision\RevisionRecord\getId(), and MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget().
DifferenceEngine::setSlotDiffOptions | ( | $options | ) |
array | $options | for the difference engine - accepts keys 'diff-type' |
Definition at line 1377 of file DifferenceEngine.php.
DifferenceEngine::setTextLanguage | ( | Language | $lang | ) |
Set the language in which the diff text is written.
Language | $lang |
Definition at line 1903 of file DifferenceEngine.php.
References $lang.
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.
Authority | $performer |
Definition at line 598 of file DifferenceEngine.php.
References hasDeletedRevision(), and isUserAllowedToSeeRevisions().
Referenced by showDiffPage().
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.
string | false | $otitle | Header for old text or false |
string | false | $ntitle | Header for new text or false |
string | $notice | HTML between diff header and body |
Definition at line 1082 of file DifferenceEngine.php.
References getDiff(), ContextSource\getOutput(), showDiffStyle(), and showMissingRevision().
Referenced by showDiffPage().
DifferenceEngine::showDiffPage | ( | $diffOnly = false | ) |
bool | $diffOnly |
Definition at line 606 of file DifferenceEngine.php.
References addHeader(), ChangeTags\formatSummaryRow(), Linker\generateRollback(), getAuthority(), getContext(), getMultiNotice(), ContextSource\getOutput(), getPermissionErrors(), ContextSource\getRequest(), getRevisionHeader(), getTitle(), ContextSource\getUser(), hasDeletedRevision(), hasSuppressedRevision(), isUserAllowedToSeeRevisions(), loadRevisionData(), markPatrolledLink(), ContextSource\msg(), renderNewRevision(), Linker\revComment(), revisionDeleteLink(), Linker\revUserTools(), shouldBeHiddenFromUser(), showDiff(), showDiffStyle(), showMissingRevision(), Linker\titleAttrib(), and userCanEdit().
DifferenceEngine::showDiffStyle | ( | ) |
Add style sheets for diff display.
Definition at line 1102 of file DifferenceEngine.php.
References ContextSource\getOutput(), and getSlotDiffRenderers().
Referenced by showDiff(), and showDiffPage().
|
private |
Definition at line 489 of file DifferenceEngine.php.
References deletedIdMarker(), ContextSource\getLanguage(), ContextSource\getOutput(), and ContextSource\msg().
Referenced by showDiff(), and showDiffPage().
|
protected |
Generates diff, to be wrapped internally in a logging/instrumentation.
string | $otext | Old text, must be already segmented |
string | $ntext | New text, must be already segmented |
Exception | If content handling for text content is configured in a way that makes maintaining B/C hard. |
Definition at line 1503 of file DifferenceEngine.php.
References CONTENT_MODEL_TEXT, getContext(), and getDebugString().
|
private |
RevisionRecord | $revRecord |
Definition at line 1710 of file DifferenceEngine.php.
References MediaWiki\Revision\RevisionRecord\userCan().
Referenced by getRevisionHeader(), and showDiffPage().
DifferenceEngine::wasCacheHit | ( | ) |
Definition at line 390 of file DifferenceEngine.php.
|
private |
Definition at line 220 of file DifferenceEngine.php.
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 179 of file DifferenceEngine.php.
|
private |
Definition at line 228 of file DifferenceEngine.php.
|
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 overriden and remain consistent with each other, so no special handling is needed.)
Definition at line 168 of file DifferenceEngine.php.
|
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 204 of file DifferenceEngine.php.
|
protected |
Definition at line 215 of file DifferenceEngine.php.
|
protected |
Was the diff fetched from cache?
Definition at line 171 of file DifferenceEngine.php.
|
protected |
Definition at line 149 of file DifferenceEngine.php.
|
protected |
Link to action=markpatrolled.
Definition at line 187 of file DifferenceEngine.php.
|
private |
Definition at line 146 of file DifferenceEngine.php.
|
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 84 of file DifferenceEngine.php.
|
protected |
Title of new revision or null if the new revision does not exist or does not belong to a page.
Since 1.32 public access is deprecated and the property can be null.
Definition at line 120 of file DifferenceEngine.php.
|
private |
New revision (right pane).
Note that this might be an unsaved revision (e.g. for edit preview). Null in case of load failure; diff methods will just return an error message in that case, and loadRevisionData() will return false. Also null until lazy-loaded. Ignored completely when isContentOverridden is set.
Definition at line 106 of file DifferenceEngine.php.
|
private |
Change tags of new revision or null if it does not exist / is not saved.
Definition at line 132 of file DifferenceEngine.php.
|
private |
Definition at line 139 of file DifferenceEngine.php.
|
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 76 of file DifferenceEngine.php.
|
protected |
Title of old revision or null if the old revision does not exist or does not belong to a page.
Since 1.32 public access is deprecated and the property can be null.
Definition at line 113 of file DifferenceEngine.php.
|
private |
Old revision (left pane).
Allowed to be an unsaved revision, unlikely that's ever needed though. False when the old revision does not exist; this can happen when using diff=prev on the first revision. Null when the revision should exist but doesn't (e.g. load failure); loadRevisionData() will return false in that case. Also null until lazy-loaded. Ignored completely when isContentOverridden is set.
Definition at line 96 of file DifferenceEngine.php.
|
private |
Change tags of old revision or null if it does not exist / is not saved.
Definition at line 126 of file DifferenceEngine.php.
|
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 184 of file DifferenceEngine.php.
|
protected |
Refresh the diff cache.
Definition at line 193 of file DifferenceEngine.php.
|
private |
Have the revisions IDs been loaded.
Definition at line 152 of file DifferenceEngine.php.
|
protected |
Have the revisions been loaded.
Definition at line 155 of file DifferenceEngine.php.
|
protected |
How many text blobs have been loaded, 0, 1 or 2?
Definition at line 158 of file DifferenceEngine.php.
|
private |
Definition at line 225 of file DifferenceEngine.php.
|
private |
A set of options that will be passed to the SlotDiffRenderer upon creation.
Definition at line 210 of file DifferenceEngine.php.
|
protected |
DifferenceEngine classes for the slots, keyed by role name.
Definition at line 196 of file DifferenceEngine.php.
|
protected |
Show rev_deleted content if allowed.
Definition at line 190 of file DifferenceEngine.php.
|
private |
Definition at line 231 of file DifferenceEngine.php.
|
private |
Constant to indicate diff cache compatibility.
Bump this when changing the diff formatting in a way that fixes important bugs or such to force cached diff views to clear.
Definition at line 68 of file DifferenceEngine.php.