From 399353d1fa0fe79c6435e2e02f5b0dee9543084b Mon Sep 17 00:00:00 2001 From: Sam Moffatt Date: Thu, 23 Aug 2012 14:00:03 -0700 Subject: [PATCH] Validate that the key parameter is a string This pull request validates that the `$key` parameter provided to the function is actually a string before trying to use this. I came across this as I was working to modify JTable to be able to support multiple primary keys in a somewhat transparent way. By default JTable passes through it's keys onto the database `insertObject` and `updateObject` function which works well for single keys but not properly for `insertObject` when the `$key` is an array. --- libraries/joomla/database/driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/joomla/database/driver.php b/libraries/joomla/database/driver.php index fd10f40167..c9bb2e4061 100644 --- a/libraries/joomla/database/driver.php +++ b/libraries/joomla/database/driver.php @@ -851,7 +851,7 @@ public function insertObject($table, &$object, $key = null) // Update the primary key if it exists. $id = $this->insertid(); - if ($key && $id) + if ($key && $id && is_string($key)) { $object->$key = $id; }