Page MenuHomePhabricator

Deferred display formats fail with cargo_compound_query
Closed, ResolvedPublic

Description

Tested on MW 1.31.2 and Cargo 2.2. When multiple queries are performed using #cargo_compound_query with dynamic display formats such as calendar, Cargo fails to return any results. For example, this query

{{#cargo_compound_query:format=calendar
|tables=SummoningFocuses
|tables=SummoningFocuses
}}

produces an XHR request with this URL (start, end, and _ omitted)

/index.php?title=Special:CargoExport
&tables[0]=SummoningFocuses&tables[1]=SummoningFocuses
&join+on[0]=&join+on[1]=
&fields[0]=&fields[1]=
&where[0]=&where[1]=
&group+by[0]=&group+by[1]=
&order+by[0][0]=`_pageName`&order+by[1][0]=`_pageName`
&limit[0]=100&limit[1]=100
&format=fullcalendar
&color[0]=&color[1]=
&text+color[0]=&text+color[1]=

which is met with a 500 Internal Server Error

MWException from line 376 of /home/hydra/public_html/extensions/Cargo/includes/CargoUtils.php: Error: unclosed string literal.

Backtrace:

#0 /home/hydra/public_html/extensions/Cargo/includes/CargoSQLQuery.php(130): CargoUtils::removeQuotedStrings(array)
#1 /home/hydra/public_html/extensions/Cargo/includes/CargoSQLQuery.php(53): CargoSQLQuery::validateValues(string, string, string, string, string, NULL, array, string, NULL)
#2 /home/hydra/public_html/extensions/Cargo/specials/CargoExport.php(46): CargoSQLQuery::newFromValues(string, string, string, string, string, NULL, array, string, NULL)
#3 /home/hydra/public_html/includes/specialpage/SpecialPage.php(565): CargoExport->execute(NULL)
#4 /home/hydra/public_html/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
#5 /home/hydra/public_html/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#6 /home/hydra/public_html/includes/MediaWiki.php(861): MediaWiki->performRequest()
#7 /home/hydra/public_html/includes/MediaWiki.php(524): MediaWiki->main()
#8 /home/hydra/public_html/index.php(42): MediaWiki->run()
#9 {main}

Replacing order by with a one-dimensional array or entirely removing it from the URL will at least turn the 500 into a 200 (this compound query will still fail because it doesn't have the calendar format's required parameters, but this is enough to illustrate the behaviour). The following is what I believe would be the most likely cause:

if ( strpos( $string, '"' ) !== false || strpos( $string, "'" ) !== false ) {
	throw new MWException( "Error: unclosed string literal." );
}

Event Timeline

Yaron_Koren claimed this task.
Yaron_Koren subscribed.

Sorry about that! This was a bug from January. I just checked in a fix for it; hopefully it will get to you soon.