Page MenuHomePhabricator

Template format drilldown tab displays unparsed
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Add template format to drilldown tabs within #cargo_declare, e.g. |_drilldownTabs=Table (format=template;intro=...;outro=...;template=templatename;named args=yes;fields=_pageName=Page,...), List
  • Go to Special:Drilldown

What happens?:

  • The template calls display unparsed, e.g. as {{templatename|Page=...|...}} {{templatename|Page=...|...}}

What should have happened instead?:

  • The template calls should be parsed.

Software version (skip for WMF-hosted wikis like Wikipedia):

  • Cargo 3.4.2 (150 d 214) 17:49, 30 June 2023.

Other information (browser name/version, screenshots, etc.):

  • It worked fine until I updated Cargo today.

Event Timeline

git checkout 3.4.1 - template displays properly.
git checkout 3.4.2 - broken again.

This seems to be the source of the problem:

diff --git a/includes/formats/CargoTemplateFormat.php b/includes/formats/CargoTemplateFormat.php
index d8bec5b..5586707 100644
--- a/includes/formats/CargoTemplateFormat.php
+++ b/includes/formats/CargoTemplateFormat.php
@@ -78,12 +78,7 @@
 		if ( array_key_exists( 'outro', $displayParams ) ) {
 			$text .= "\n" . $displayParams['outro'] . "\n";
 		}
-		global $wgTitle;
-		if ( $wgTitle != null && $wgTitle->isSpecialPage() ) {
-			return CargoUtils::smartParse( $text, $this->mParser );
-		} else {
-			return $text;
-		}
+		return $text;
 	}
 
 }

When I undo that change, the template format displays correctly on Special:Drilldown.

@Bawolff I think pinging you here will subscribe you to this task.

The following seems to fix the problem:

diff --git a/drilldown/CargoDrilldownPage.php b/drilldown/CargoDrilldownPage.php
index 751281c..b8f3513 100644
--- a/drilldown/CargoDrilldownPage.php
+++ b/drilldown/CargoDrilldownPage.php
@@ -2130,7 +2130,11 @@ END;
                                }
                        }
                        $html = $queryDisplayer->displayQueryResults( $formatter, $queryResults );
-                       $out->addHTML( $html );
+                       if ( $this->format === 'template' ) {
+                               $out->addWikiTextAsContent( $html );
+                       } else {
+                               $out->addHTML( $html );
+                       }

                        return;
                } else {

I just copied the equivalent text from what was added to CargoQueryPage.php at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cargo/+/893819/7/includes/CargoQueryPage.php#198.

I've added it in the first half of if ( !$isDeferred ) and don't know whether anything has to be added to the else part too.

Change 935487 had a related patch set uploaded (by Yaron Koren; author: Yaron Koren):

[mediawiki/extensions/Cargo@master] Fix for template format display in Special:Drilldown

https://gerrit.wikimedia.org/r/935487

Change 935487 merged by jenkins-bot:

[mediawiki/extensions/Cargo@master] Fix for template format display in Special:Drilldown

https://gerrit.wikimedia.org/r/935487

Yaron_Koren claimed this task.

Thanks for the patch!