Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
1.6 - Major issues with soft delete
  • Hi,

    To begin, I'd like to thank all the fuelphp team for building this awesome framework :)

    I've upgraded from 1.5.3 to 1.6 a few days ago and now I'm facing ORM issues (using soft delete feature).

    1. When performing a basic select query, the result array contain deleted items.

    For example, let's consider this query :

    $objects = Model_User_Photo::query()
                ->where('user_id', 123)
                ->order_by('created_at', 'DESC')
                ->get();

    In 1.5.x, this query returns only non deleted items.
    In 1.6, this returns non-deleted AND deleted items.

    2. Each time I'm deleting an item, I get this error :

    Notice!
    Fuel\Core\PhpErrorException [ Notice ]: Trying to get property of non-object
    PKGPATH/orm/classes/belongsto.php @ line 159

    My model:

    class Model_User_Photo extends \Orm\Model_Soft
    {
        protected static $_properties = array(
            'id',
            'user_id',
            'original_filename',
            'filename',
            'bucket',
            'width',
            'height',
            'formats' => array(
                'data_type' => 'serialize',
            ),
            'created_at',
            'updated_at',
            'deleted_at',
        );

        protected static $_soft_delete = array(
            'deleted_field' => 'deleted_at',
            'mysql_timestamp' => false,
        );

        protected static $_belongs_to = array(
            'user' => array(
                'key_from' => 'user_id',
                'model_to' => 'Model_User',
                'key_to' => 'id',
                'cascade_save' => false,
                'cascade_delete' => false,
            ),
        );

        protected static $_observers = array(
            'Orm\Observer_CreatedAt' => array(
                'events' => array('before_insert'),
                'mysql_timestamp' => false,
            ),
            'Orm\Observer_UpdatedAt' => array(
                'events' => array('before_save'),
                'mysql_timestamp' => false,
            ),
            'Orm\\Observer_Typing' => array(
                'events' => array('before_save', 'after_save', 'after_load'),
            ),
        );

        // ...
        // My methods here
        // ...
    }
  • HarroHarro
    Accepted Answer
    For the query bit, an issue was already opened: https://github.com/fuel/orm/issues/256

    For the belongs_to notice, the issue https://github.com/fuel/orm/issues/255 was fixed in 1.7/develop. You can backport fuel/packages/orm/classes/belongsto.php to get it fixed in your installation, a 1.6.1 hotfix will be released sometime next week.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion