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

PHP Deprecated: As of 4.5.0, using newQuery() is deprecated #2251

Open
malle-pietje opened this issue Dec 19, 2023 · 10 comments
Open

PHP Deprecated: As of 4.5.0, using newQuery() is deprecated #2251

malle-pietje opened this issue Dec 19, 2023 · 10 comments

Comments

@malle-pietje
Copy link

Running a migration with Phinx v 0.13.4 I get this error message:

 == 20221014105116 ModifyPermissionForGlobalStyling: migrating 
PHP Deprecated:  As of 4.5.0, using newQuery() is deprecated. Instead, use `insertQuery()`, `deleteQuery()`, `selectQuery()` or `updateQuery()`. The query objects returned by these methods will emit deprecations that will become fatal errors in 5.0.See https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html for more information.
/xyz/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php, line: 214
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `xyz/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only. in /xyz/vendor/cakephp/core/functions.php on line 318

(the paths above have been sanitized a bit)

I believe the triggering migration code (sanitized a bit) is this:

        $builder = $this->getQueryBuilder();
        $builder
            ->update('xxxxxx')
            ->set('yyyy', 'zzzzzzz')
            ->where(['yyyy' => 'aaaaaaaaaaa'])
            ->execute();

I also noticed the same error was submitted as an issue in the CakePHP repo:
cakephp/migrations#651

Is there anything I can do to prevent this deprecation error message from appearing?

@dereuromark
Copy link
Member

dereuromark commented Dec 19, 2023

Might also be related to
#2242
Which is now in v0.15 version release.

You can backport this to v0.14 one if needed.
v0.13 might be EOL now.

@MasterOdin
Copy link
Member

To address cakephp/migrations#651 and this issue, we'd need to backport #2242 to v0.13. There is also the changes to getQueryBuilder from 37307f8 that might be useful (though make it optional to pass argument and if no argument, default to current behavior of using newQuery vs throwing exception).

Granted, given that newQuery in favor of using the specific methods was deprecated in cakephp and the type problems with getQueryBuilder that motivated #2242, I wonder if we shouldn't also deprecate getQueryBuilder to be removed in 0.16 as well. Thoughts on that @dereuromark?

@dereuromark
Copy link
Member

Why not backport to 0.14 only? Shouldn't be any need to still use 0.13 afaik
See wiki

@MasterOdin
Copy link
Member

MasterOdin commented Dec 19, 2023

Biggest reason would be to help cakephp/migrations@v3 users, but if you don't think you'd want those methods in phinx proper for that (or fine with just having those users be stuck with the deprecation warnings), then yeah, less of a reason to backport that far unless @malle-pietje provides a compelling reason on why they might be stuck on 0.13.

@malle-pietje
Copy link
Author

Thanks for all the feedback!

I'm stuck with 0.13 because a large number of deployments of our application are still on PHP 7.4, we could move to 0.14.

@malle-pietje
Copy link
Author

I checked and the reason we had to pin to version 0.13 has been fixed so we should be able to move to 0.14. That means a backport would be welcome for us and any other projects that need to support PHP 7.4.

I know, PHP 7.4 is EOL but you don't want to know how many servers are still running it... Forcing them to upgrade is going to put extra load on our team 😉

@dereuromark
Copy link
Member

0.14 backport is fine, even supporting 7.4 here totally OK, no worries. Thats still the min version for the Cake4 series.
A backport PR would be welcome here.

@malle-pietje
Copy link
Author

I'll see whether I can find the time to look into the backport in the short term. If someone who's more familiar with the package is willing to look into this, that's obviously more than welcome! 🤞

@nook24
Copy link

nook24 commented Jan 4, 2024

Same for me. At the moment we have to support PHP 7.4 because it is part of Ubuntu 20.04 which is still in support until Apr 2025. Even if PHP 7.4 itself is EOL.

@ajiho
Copy link

ajiho commented May 12, 2024

My solution is to install the dependent version in advance .

Define the following content in the require field of your composer.json

    "cakephp/core": "~4.3.0",
    "cakephp/utility": "~4.3.0",
    "cakephp/datasource": "~4.3.0",
    "cakephp/database": "~4.3.0",
    "robmorgan/phinx": "~0.13.0",

run composer update

It can work normally until your project can be migrated to the latest phinx

If you are unsure of the dependencies, you can use the following instructions to view them

composer show cakephp/database -t

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