updateCollection() ignores criteria
$c = $modx->newQuery('modResource'); $c->where(array('class_key' => 'modDocument')); $modx->updateCollection('modResource', array('class_key' => 'extResource'), $c);
This code should update only resources with class_key set to 'modDocument'.
It updates every resource for me - a not easily reversible disaster. ;)
The count using $c with getCollection() is correct, so the problem is not with the criteria. Adding $c->prepare() is no help.
Unfortunately, updateCollection() only works with an array of criteria at the moment, and not with an xPDOQuery instance as you might expect.
If you reworked that as...
$modx->updateCollection(
'modResource',
array('class_key' => 'extResource'),
array('class_key' => 'modDocument')
);
it should work as expected.
Might worth updating the PHPDoc then.
I assume the same goes for removeCollection, right ?