Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/227737
Change subject: Added validation to CargoUtils::getTableSchemas()
......................................................................
Added validation to CargoUtils::getTableSchemas()
Change-Id: I0db525403eaf6151faf69c5173c7bb3dbc2d1744
---
M CargoSQLQuery.php
M CargoUtils.php
2 files changed, 14 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo
refs/changes/37/227737/1
diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index 6044228..6b14ce9 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -101,8 +101,10 @@
* some of the parameters need to be checked for these strings,
* but we might as well validate all of them.
*
- * The function setDescriptionsForFields() also does specific
- * validation of the "tables=" and "fields=" parameters.
+ * The function CargoUtils::getTableSchemas() also does specific
+ * validation of the "tables" parameter, while this class's
+ * setDescriptionsForFields() does validation of the "fields="
+ * parameter.
*/
public static function validateValues( $tablesStr, $fieldsStr,
$whereStr, $joinOnStr, $groupByStr,
$havingStr, $orderByStr, $limitStr ) {
diff --git a/CargoUtils.php b/CargoUtils.php
index 1d6ed2c..f971e02 100644
--- a/CargoUtils.php
+++ b/CargoUtils.php
@@ -149,6 +149,16 @@
$tableSchemaString = $row['table_schema'];
$tableSchemas[$tableName] =
CargoTableSchema::newFromDBString( $tableSchemaString );
}
+
+ // Validate the table names.
+ if ( count( $tableSchemas ) < count( $mainTableNames ) ) {
+ foreach ( $mainTableNames as $tableName ) {
+ if ( !array_key_exists( $tableName,
$tableSchemas ) ) {
+ throw new MWException( "Error: table
\"$tableName\" not found." );
+ }
+ }
+ }
+
return $tableSchemas;
}
--
To view, visit https://gerrit.wikimedia.org/r/227737
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0db525403eaf6151faf69c5173c7bb3dbc2d1744
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits