$changed = $this->opts->getChangedValues();
unset( $changed['offset'] ); // Reset offset if query type changes
+ // wfArrayToCgi(), called from LinkRenderer/Title, will not output null and false values
+ // to the URL, which would omit some options (T158504). Fix it by explicitly setting them
+ // to 0 or 1.
+ $changed = array_map( function ( $value ) {
+ return $value ? '1' : '0';
+ }, $changed );
+
$self = $this->getPageTitle();
$linkRenderer = $this->getLinkRenderer();
foreach ( $filters as $key => $msg ) {
protected function form() {
$out = $this->getOutput();
- $out->addModules( 'mediawiki.userSuggest' );
// Consume values
$this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
}
$hidden = implode( "\n", $hidden );
- $form = [
+ $formDescriptor = [
'namespace' => [
'type' => 'namespaceselect',
'name' => 'namespace',
'default' => $tagFilterVal,
],
'username' => [
- 'type' => 'text',
+ 'type' => 'user',
'name' => 'username',
'label-message' => 'newpages-username',
'default' => $userText,
'id' => 'mw-np-username',
'size' => 30,
- 'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
],
'size' => [
'type' => 'sizefilter',
],
];
- $htmlForm = new HTMLForm( $form, $this->getContext() );
-
- $htmlForm->setSubmitText( $this->msg( 'newpages-submit' )->text() );
- $htmlForm->setSubmitProgressive();
- // The form should be visible on each request (inclusive requests with submitted forms), so
- // return always false here.
- $htmlForm->setSubmitCallback(
- function () {
- return false;
- }
- );
- $htmlForm->setMethod( 'get' );
-
- $out->addHTML( Xml::fieldset( $this->msg( 'newpages' )->text() ) );
-
- $htmlForm->show();
-
- $out->addHTML(
- Html::rawElement(
+ $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
+ $htmlForm
+ ->setMethod( 'get' )
+ ->setFormIdentifier( 'newpagesform' )
+ // The form should be visible on each request (inclusive requests with submitted forms), so
+ // return always false here.
+ ->setSubmitCallback(
+ function () {
+ return false;
+ }
+ )
+ ->setSubmitText( $this->msg( 'newpages-submit' )->text() )
+ ->setWrapperLegend( $this->msg( 'newpages' )->text() )
+ ->addFooterText( Html::rawElement(
'div',
null,
$this->filterLinks()
- ) .
- Xml::closeElement( 'fieldset' )
- );
+ ) )
+ ->show();
+ $out->addModuleStyles( 'mediawiki.special' );
}
/**
- * @param stdClass $row Result row from recent changes
- * @return Revision|bool
+ * @param stdClass $result Result row from recent changes
+ * @param Title $title
+ * @return bool|Revision
*/
- protected function revisionFromRcResult( stdClass $result ) {
+ protected function revisionFromRcResult( stdClass $result, Title $title ) {
return new Revision( [
- 'comment' => $result->rc_comment,
+ 'comment' => CommentStore::getStore()->getComment( 'rc_comment', $result )->text,
'deleted' => $result->rc_deleted,
'user_text' => $result->rc_user_text,
'user' => $result->rc_user,
- ] );
+ 'actor' => $result->rc_actor,
+ ], 0, $title );
}
/**
// Revision deletion works on revisions,
// so cast our recent change row to a revision row.
- $rev = $this->revisionFromRcResult( $result );
- $rev->setTitle( $title );
+ $rev = $this->revisionFromRcResult( $result, $title );
$classes = [];
$attribs = [ 'data-mw-revid' => $result->rev_id ];
# Display the old title if the namespace/title has been changed
$oldTitleText = '';
$oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title );
- $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
- . "{$tagDisplay} {$oldTitleText}";
-
- // Let extensions add data
- Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
- $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
-
- if ( count( $classes ) ) {
- $attribs['class'] = implode( ' ', $classes );
- }
if ( !$title->equals( $oldTitle ) ) {
$oldTitleText = $oldTitle->getPrefixedText();
);
}
+ $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
+ . "{$tagDisplay} {$oldTitleText}";
+
+ // Let extensions add data
+ Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
+ $attribs = array_filter( $attribs,
+ [ Sanitizer::class, 'isReservedDataAttribute' ],
+ ARRAY_FILTER_USE_KEY
+ );
+
+ if ( count( $classes ) ) {
+ $attribs['class'] = implode( ' ', $classes );
+ }
+
return Html::rawElement( 'li', $attribs, $ret ) . "\n";
}
}
protected function feedItemAuthor( $row ) {
- return isset( $row->rc_user_text ) ? $row->rc_user_text : '';
+ return $row->rc_user_text ?? '';
}
protected function feedItemDesc( $row ) {
- $revision = $this->revisionFromRcResult( $row );
- if ( $revision ) {
- // XXX: include content model/type in feed item?
- return '<p>' . htmlspecialchars( $revision->getUserText() ) .
- $this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
- htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
- "</p>\n<hr />\n<div>" .
- nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
+ $revision = Revision::newFromId( $row->rev_id );
+ if ( !$revision ) {
+ return '';
+ }
+
+ $content = $revision->getContent();
+ if ( $content === null ) {
+ return '';
}
- return '';
+ // XXX: include content model/type in feed item?
+ return '<p>' . htmlspecialchars( $revision->getUserText() ) .
+ $this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
+ htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
+ "</p>\n<hr />\n<div>" .
+ nl2br( htmlspecialchars( $content->serialize() ) ) . "</div>";
}
protected function getGroupName() {