engines.
* Skin::escapeSearchLink() is deprecated. Use Skin::getSearchLink() or the skin
template option 'searchaction' instead.
+* Skin::getRevisionId() and Skin::isRevisionCurrent() have been deprecated.
+ Use OutputPage::getRevisionId() and OutputPage::isRevisionCurrent() instead.
* LoadBalancer::haveIndex() and LoadBalancer::isNonZeroLoad() have
been deprecated.
* FileBackend::getWikiId() has been deprecated.
return $this->mRevisionId;
}
+ /**
+ * Whether the revision displayed is the latest revision of the page
+ *
+ * @since 1.34
+ * @return bool
+ */
+ public function isRevisionCurrent() {
+ return $this->mRevisionId == 0 || $this->mRevisionId == $this->getTitle()->getLatestRevID();
+ }
+
/**
* Set the timestamp of the revision which will be displayed. This is used
* to avoid a extra DB call in Skin::lastModified().
/**
* Get the current revision ID
*
+ * @deprecated since 1.34, use OutputPage::getRevisionId instead
* @return int
*/
public function getRevisionId() {
/**
* Whether the revision displayed is the latest revision of the page
*
+ * @deprecated since 1.34, use OutputPage::isRevisionCurrent instead
* @return bool
*/
public function isRevisionCurrent() {
- $revID = $this->getRevisionId();
- return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
+ return $this->getOutput()->isRevisionCurrent();
}
/**
* @return string HTML text with an URL
*/
function printSource() {
- $oldid = $this->getRevisionId();
+ $oldid = $this->getOutput()->getRevisionId();
if ( $oldid ) {
$canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
$url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
function getCopyright( $type = 'detect' ) {
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
if ( $type == 'detect' ) {
- if ( !$this->isRevisionCurrent()
+ if ( !$this->getOutput()->isRevisionCurrent()
&& !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
) {
$type = 'history';
# No cached timestamp, load it from the database
if ( $timestamp === null ) {
- $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
+ $timestamp = Revision::getTimestampFromId( $this->getTitle(),
+ $this->getOutput()->getRevisionId() );
}
if ( $timestamp ) {
function editUrlOptions() {
$options = [ 'action' => 'edit' ];
- if ( !$this->isRevisionCurrent() ) {
- $options['oldid'] = intval( $this->getRevisionId() );
+ if ( !$this->getOutput()->isRevisionCurrent() ) {
+ $options['oldid'] = intval( $this->getOutput()->getRevisionId() );
}
return $options;
$tpl->set( 'credits', false );
$tpl->set( 'numberofwatchingusers', false );
if ( $title->exists() ) {
- if ( $out->isArticle() && $this->isRevisionCurrent() ) {
+ if ( $out->isArticle() && $out->isRevisionCurrent() ) {
if ( $wgMaxCredits != 0 ) {
/** @var CreditsAction $action */
$action = Action::factory(
// Whether to show the "Add a new section" tab
// Checks if this is a current rev of talk page and is not forced to be hidden
$showNewSection = !$out->forceHideNewSectionLink()
- && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
+ && ( ( $isTalk && $out->isRevisionCurrent() ) || $out->showNewSectionLink() );
$section = $request->getVal( 'section' );
if ( $title->exists()
if ( $out->isArticle() ) {
// Also add a "permalink" while we're at it
- $revid = $this->getRevisionId();
+ $revid = $this->getOutput()->getRevisionId();
if ( $revid ) {
$nav_urls['permalink'] = [
'text' => $this->msg( 'permalink' )->text(),
];
}
+ /**
+ * @param int $titleLastRevision Last Title revision to set
+ * @param int $outputRevision Revision stored in OutputPage
+ * @param bool $expectedResult Expected result of $output->isRevisionCurrent call
+ * @covers OutputPage::isRevisionCurrent
+ * @dataProvider provideIsRevisionCurrent
+ */
+ public function testIsRevisionCurrent( $titleLastRevision, $outputRevision, $expectedResult ) {
+ $titleMock = $this->getMock( Title::class, [], [], '', false );
+ $titleMock->expects( $this->any() )
+ ->method( 'getLatestRevID' )
+ ->willReturn( $titleLastRevision );
+
+ $output = $this->newInstance( [], null, [ 'notitle' => true ] );
+ $output->setTitle( $titleMock );
+ $output->setRevisionId( $outputRevision );
+ $this->assertEquals( $expectedResult, $output->isRevisionCurrent() );
+ }
+
+ public function provideIsRevisionCurrent() {
+ return [
+ [ 10, null, true ],
+ [ 42, 42, true ],
+ [ null, 0, true ],
+ [ 42, 47, false ],
+ [ 47, 42, false ]
+ ];
+ }
+
/**
* @return OutputPage
*/