Git Product home page Git Product logo

Comments (5)

danabyrd avatar danabyrd commented on July 29, 2024

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?

from yii2-relation-trait.

strtob avatar strtob commented on July 29, 2024

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:

  • $lock = db_lock (this is my lock column name)
  • $rows = 0

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?

from yii2-relation-trait.

strtob avatar strtob commented on July 29, 2024

Anybody got any idea where is the problem? :-(

from yii2-relation-trait.

danabyrd avatar danabyrd commented on July 29, 2024

@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.

from yii2-relation-trait.

strtob avatar strtob commented on July 29, 2024

Thank you :-)

from yii2-relation-trait.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.