* @file
*/
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
/**
* List for revision table items for a single page
*/
/** @var ResultWrapper|bool */
protected $res;
- /** @var bool|object */
+ /** @var bool|Revision */
protected $current;
/**
}
public function key() {
- return $this->res ? $this->res->key(): 0;
+ return $this->res ? $this->res->key() : 0;
}
public function valid() {
return false;
}
+ /**
+ * Get the DB field name storing actor ids.
+ * Override this function.
+ * @since 1.31
+ * @return bool
+ */
+ public function getAuthorActorField() {
+ return false;
+ }
+
/**
* Get the ID, as it would appear in the ids URL parameter
* @return int
return strval( $this->row->$field );
}
+ /**
+ * Get the author actor ID
+ * @since 1.31
+ * @return string
+ */
+ public function getAuthorActor() {
+ $field = $this->getAuthorActorField();
+ return strval( $this->row->$field );
+ }
+
/**
* Returns true if the current user can view the item
*/
* This is used to show the list in HTML form, by the special page.
*/
abstract public function getHTML();
+
+ /**
+ * Returns an instance of LinkRenderer
+ * @return \MediaWiki\Linker\LinkRenderer
+ */
+ protected function getLinkRenderer() {
+ return MediaWikiServices::getInstance()->getLinkRenderer();
+ }
}
class RevisionList extends RevisionListBase {
if ( $this->ids !== null ) {
$conds['rev_id'] = array_map( 'intval', $this->ids );
}
+ $revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
return $db->select(
- [ 'revision', 'page', 'user' ],
- array_merge( Revision::selectFields(), Revision::selectUserFields() ),
+ $revQuery['tables'],
+ $revQuery['fields'],
$conds,
__METHOD__,
[ 'ORDER BY' => 'rev_id DESC' ],
- [
- 'page' => Revision::pageJoinCond(),
- 'user' => Revision::userJoinCond() ]
+ $revQuery['joins']
);
}
* @return string
*/
protected function getRevisionLink() {
- $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
- $this->revision->getTimestamp(), $this->list->getUser() ) );
+ $date = $this->list->getLanguage()->userTimeAndDate(
+ $this->revision->getTimestamp(), $this->list->getUser() );
if ( $this->isDeleted() && !$this->canViewContent() ) {
- return $date;
+ return htmlspecialchars( $date );
}
- return Linker::linkKnown(
+ $linkRenderer = $this->getLinkRenderer();
+ return $linkRenderer->makeKnownLink(
$this->list->title,
$date,
[],
if ( $this->isDeleted() && !$this->canViewContent() ) {
return $this->context->msg( 'diff' )->escaped();
} else {
- return Linker::linkKnown(
+ $linkRenderer = $this->getLinkRenderer();
+ return $linkRenderer->makeKnownLink(
$this->list->title,
- $this->list->msg( 'diff' )->escaped(),
+ $this->list->msg( 'diff' )->text(),
[],
[
'diff' => $this->revision->getId(),