When testing against a page creation in RC, set page_id to 0 as in the real filtering

Bug: T334617
Change-Id: Id4465cb36131b745d386168e7e158b6bb4d6418c
This commit is contained in:
Jean-Luc Hassec 2023-04-13 08:55:35 +00:00 committed by [[mw:User:Od1n]]
parent e89e094ffa
commit 9369d08773
3 changed files with 7 additions and 2 deletions

View file

@ -83,7 +83,7 @@ class RCVariableGenerator extends VariableGenerator {
return null;
}
} elseif ( $this->rc->getAttribute( 'rc_this_oldid' ) ) {
// It's an edit.
// It's an edit (or a page creation).
$this->addEditVarsForRow();
} elseif (
!$this->hookRunner->onAbuseFilterGenerateVarsForRecentChange(

View file

@ -129,7 +129,11 @@ class VariableGenerator {
string $prefix,
RecentChange $rc = null
): self {
$this->vars->setVar( $prefix . '_id', $title->getArticleID() );
if ( $rc && $rc->getAttribute( 'rc_type' ) == RC_NEW ) {
$this->vars->setVar( $prefix . '_id', 0 );
} else {
$this->vars->setVar( $prefix . '_id', $title->getArticleID() );
}
$this->vars->setVar( $prefix . '_namespace', $title->getNamespace() );
$this->vars->setVar( $prefix . '_title', $title->getText() );
$this->vars->setVar( $prefix . '_prefixedtitle', $title->getPrefixedText() );

View file

@ -64,6 +64,7 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
switch ( $type ) {
case 'create':
$expectedValues['page_id'] = 0;
$expectedValues['old_wikitext'] = '';
$expectedValues['old_content_model'] = '';
// Fallthrough