private function _fixNonUserDependentTimezone($offsets, \b2db\Table $table, $correctionfield, $scope, $testfield = null) { $crit = $table->getCriteria(); $crit->addWhere($table::SCOPE, $scope->getID()); $res = $table->doSelect($crit); if (is_null($res)) { return; // nothing to update } while ($row = $res->getNextRow()) { if ($testfield !== null) { if ($row->get($testfield) != 1) { continue; } } $offset = $offsets['system']; $crit2 = $table->getCriteria(); if (!is_array($correctionfield)) { $correctionfield = array($correctionfield); } $added = 0; foreach ($correctionfield as $field) { // If the timestamp is 0, don't correct as it is unset if ($row->get($field) == 0) { continue; } $crit2->addUpdate($field, (int) $row->get($field) + $offset); $added = 1; // Mark that we have actually added something } // Don't update if no addUpdate calls made if ($added == 1) { $crit2->addWhere($table::ID, $row->get($table::ID)); $table->doUpdate($crit2); } } }