List of steps to reproduce (step by step, including full links if applicable):
- add a faulty query to any table declaring template or templates called within that template
- e.g., {{#vardefine:testvar|}} {{#cargo_query:tables=my_table|fields=my_field|where=_pageID = {{#var:testvar}} }}
- the var is added to demonstrate a bit more complexity when designing queries, the final sql will contain an empty where condition like WHERE _pageID =
- run cargoRecreateData.php --table=my_table
What happens?:
the cargoRecreateData.php maintenance script prematurely exits with status 1
What should have happened instead?:
well, this is of course highly debatable, but I propose that the cargoRecreateData.php script doesn't necessarily need to exit with status 1 for every sql error caused by a cargo query call; in our case it's more likely to be a display issue rather than a storage issue
Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
Cargo since b68e9128a77843f91ca152fa3c96c6e6ecd6565b
Proposed "fix"
based on commit b68e9128a77843f91ca152fa3c96c6e6ecd6565b, i'd propose to catch exceptions caused after calling CargoSQLQuery::run(). this would be consistent with the actual $sqlQuery->run() at line 147 in CargoQuery.php in the same commit.
diff --git a/includes/parserfunctions/CargoQuery.php b/includes/parserfunctions/CargoQuery.php index 6b1f0e1..498ee21 100644 --- a/includes/parserfunctions/CargoQuery.php +++ b/includes/parserfunctions/CargoQuery.php @@ -96,10 +96,10 @@ class CargoQuery { } $sqlQueryJustForResultsTitle = CargoSQLQuery::newFromValues( $tablesStr, $newFieldsStr, $whereStr, $joinOnStr, $groupByStr, $havingStr, $orderByStr, '', $offsetStr ); + $queryResultsJustForResultsTitle = $sqlQueryJustForResultsTitle->run(); } catch ( Exception $e ) { return CargoUtils::formatError( $e->getMessage() ); } - $queryResultsJustForResultsTitle = $sqlQueryJustForResultsTitle->run(); // Let's collect all special _pageID entries $pageIdForBacklinks = []; foreach ( $fieldsToCollectForPageIds as $fieldToCollectForPageIds ) {
what's your opinion on this?