Skip to content

Commit 2425a0a

Browse files
authored
Run validators only for root object in xPDOObjectVehicle install (#267)
Validators are vehicle-level and were incorrectly invoked for each related object (1 + N times). Now validate() runs only when $parentObject === null (root object installation). Resolves modxcms/revolution#16223
1 parent da64dbf commit 2425a0a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/xPDO/Transport/xPDOObjectVehicle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function _installObject(& $transport, $options, $element, & $parentObj
139139
if (!empty ($vOptions[xPDOTransport::PREEXISTING_MODE])) {
140140
$preExistingMode = intval($vOptions[xPDOTransport::PREEXISTING_MODE]);
141141
}
142-
if ($this->validate($transport, $object, $vOptions)) {
142+
if ($parentObject !== null || $this->validate($transport, $object, $vOptions)) {
143143
if (!$this->_installRelated($transport, $object, $element, $options, 'foreign')) {
144144
$transport->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not install related objects with foreign owned keys for vehicle object of class {$vClass}; criteria: " . print_r($criteria, true));
145145
if ($transport->xpdo->getDebug() === true) $transport->xpdo->log(xPDO::LOG_LEVEL_DEBUG, 'Could not install related objects for vehicle: ' . print_r($vOptions, true));

0 commit comments

Comments
 (0)