Description of Problem:
When trying to filter Context Settings (in the System/Contexts menu) to a specific sub-area on my development environment I get a JavaScript crash because of an attempt to parse a JSON array that is in fact a PHP warning string. The warning string consists of multiple "Array to String conversion" errors in calls to 'bindValue' in the 'bind' function of xPDOCriteria. This in turn can be traced back to the parseConditions function in xPDOQuery.
The parseConditions function has two main paths, depending on the results of this test:
if (isset ($conditions[0]) && !$this->isConditionalClause($conditions[0]) && is_array($pk) && count($conditions) == count($pk)) {
In the specific case I'm seeing, there are two conditions (context and area), but the primary key for the table also has two columns (context_key and key), so the code follows the 'true' path of the 'if' statement. I
think it's making an assumption that if the number of conditions matches the number of columns in the primary key, then the conditions
are for the primary key.
But this isn't true here...
So the code doesn't split up the $condition[i] (which is an array) into its key/value pair, and instead binds $field['binding']['value'] to the whole $condition[i] - which ultimately gets passed to the 'bindValue' function as its 'value' parameter - which cannot be an array.
Does anyone know what the logic in this 'if' clause is meant to be doing?
Cheers!
- MODX Version: 2.2.7
- PHP Version: 5.4
- Database Version: SQL Server (but the code path above is the same for MySql)
- Additional Server Info: Windows 7, IIS 7.5
- Installed MODX Add-ons: