joomla/joomla-cms — pull request #3842 by itbra (2014-06-30 10:46:28+00:00)
Title: JTable constructor not considering the null-value for the primary key breaks JTable::reset()

`JTable::_construct($table, $key, $db)` initialises several class fields such as `JTable::$_tbl_keys`. When the constructor parameter `$key` is properly initialised and assigned to the field `JTable::$_tbl_keys` overriding its default value the class field `JTable::$_tbl_keys` may get broken. Consider the case where the constructor parameter `$key` becomes null due to the null-value passed in for it. Through the assignment to `JTable::$_tbl_keys` that class fields value becomes null too which will cause trouble.

For example `JTable::reset()`, which executes an `in_array()` based on `JTable::$_tbl_keys`. This check then fails with the following error:

in_array() expects parameter 2 to be array, null given in /libraries/joomla/table/table.php on line 563

because `JTable::$_tbl_keys` value is null.

This pull request extends the constructor to consider the null-value and initialise $key with an empty array in case the passed in value is null.