Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.3 PHP 7.2.1 compatibility in SoftDeletes #22843

Closed
drjonnicholson opened this issue Jan 18, 2018 · 5 comments
Closed

Laravel 5.3 PHP 7.2.1 compatibility in SoftDeletes #22843

drjonnicholson opened this issue Jan 18, 2018 · 5 comments

Comments

@drjonnicholson
Copy link

  • Laravel Version: 5.3.*-dev
  • PHP Version: 7.2.1-1+ubuntu16.04.1 (in homestead)
  • Database Driver & Version: ?

Description:

Calling delete on a model with the SoftDeletes trait causes a count(NULL) failure due to how count() now processes null values.

Exception:

ErrorException: count(): Parameter must be an array or an object that implements Countable in /home/vagrant/***/vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php:55

Offending code:

    protected function getDeletedAtColumn(Builder $builder)
    {
        if (count($builder->getQuery()->joins) > 0) {
            return $builder->getModel()->getQualifiedDeletedAtColumn();
        }
        return $builder->getModel()->getDeletedAtColumn();
    }

Suggested fix, use version from Laravel 5.5/5.6:

    protected function getDeletedAtColumn(Builder $builder)
    {
        if (count((array) $builder->getQuery()->joins) > 0) {
            return $builder->getModel()->getQualifiedDeletedAtColumn();
        }
        return $builder->getModel()->getDeletedAtColumn();
    }

Steps To Reproduce:

Try something like:

MyModel::where('id', 1)->delete();
@ntzm
Copy link
Contributor

ntzm commented Jan 18, 2018

That version is no longer supported, you need to update to a newer version of Laravel

@zulrang
Copy link

zulrang commented Jan 18, 2018

@taylorotwell Mentioned in the docs repo that he wants 5.1 to support PHP 7.2

@drjonnicholson
Copy link
Author

@ntzm, that’s not a helpful answer. As far as I can see there is no statement in the git read me or the main website about 5.3 no longer being supported (both happily document 5.2 onwards)

Additionally, active support compared to bug fix support are two different issues. I don’t expect new features - just the existing ones to work.

Note that, as in my original post, the same issue is fixed elsewhere in the version we are using, it’s a simple fix.

When we can we will update, but at the moment it’s not possible. In our development roadmap.

@devcircus
Copy link
Contributor

According to laravel-news, all support for 5.3 has long passed, even security. That's not written in stone though, so IMO, the best option would probably be a quick pull request for 5.3 as a bug-fix with an explanation. Taylor will be sure to see it then.

@drjonnicholson
Copy link
Author

I've posted a pull request here #22858

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants