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:
- CargoExport::execute [[ https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Cargo/+/master/specials/CargoExport.php#38 | obtains the order by parameter as an array]].
- Each array element, which is itself also an array, is passed to CargoSQLQuery::newFromValues, to validateValues, and eventually to removeQuotedStrings, as indicated by the backtrace.
- The code below always throws, because strpos returns null if $string is an array, and null !== false:
if ( strpos( $string, '"' ) !== false || strpos( $string, "'" ) !== false ) { throw new MWException( "Error: unclosed string literal." ); }