Open strtob opened 5 years ago
yiisoft/yii2/db/BaseActiveRecord.php What version of yii are you using? Line 81 of 2.16.1 looks like this: if ($lock !== null && !$rows) {
Can you try it on 2.16.1 without breaking your project?
Can you think of a test I could do to verify the behavior you want is working?
Thank you for your help, unfortunately, I still have the problem also with v 2.16.1
` Stale Object Exception – yii\db\StaleObjectException The object being updated is outdated.
1. in C:\Users\none\work\rebase\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 813
804805806807808809810811812813814815816817818819820821822
if ($lock !== null) {
$values[$lock] = $this->$lock + 1;
$condition[$lock] = $this->$lock;
}
// We do not check the return value of updateAll() because it's possible
// that the UPDATE statement doesn't change anything and thus returns 0.
$rows = static::updateAll($values, $condition);
if ($lock !== null && !$rows) {
throw new StaleObjectException('The object being updated is outdated.');
}
if (isset($values[$lock])) {
$this->$lock = $values[$lock];
}
$changedAttributes = [];
foreach ($values as $name => $value) {
$changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
`
error_log dump:
the comment of the BaseActiveRecord is like this:
// We do not check the return value of updateAll() because it's possible // that the UPDATE statement doesn't change anything and thus returns 0. $rows = static::updateAll($values, $condition);
But why should this condition ($lock is the column name && no updates) throws an error?
Anybody got any idea where is the problem? :-(
@strtob I don't know the cause yet. I've setup a test harness to run an x-debug trace on my database.
Thanks for the information you have sent so far. I will let you know what I find.
Thank you :-)
Hi,
I've built a crud app with mootensai/yii2-enhanced-gii, there are related tables by foreign keys (n:1, n:m).
In the case I got an validation error, after pressing update a second time the app throw the following error:
`Stale Object Exception – yii\db\StaleObjectException The object being updated is outdated.
`
anybody an idea what's the problem?
Cheers!