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

Using newQuery() is deprecated. Instead, use insertQuery(), deleteQuery(), selectQuery() or updateQuery() #651

Open
1 of 3 tasks
nook24 opened this issue Oct 25, 2023 · 0 comments
Labels

Comments

@nook24
Copy link
Contributor

nook24 commented Oct 25, 2023

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 4.5.0

  • Migrations plugin version: 3.9.0 @stable in composer.json

  • Bake plugin version (if relevant): EXACT RELEASE VERSION OR COMMIT HASH, HERE.

  • Database server mysql Ver 8.0.34-0ubuntu0.22.04.1

  • PHP Version: PHP 8.1.2-1ubuntu2.14

  • Platform / OS: Ubuntu and RHEL

What you did

When using CakePHP 4.5.0 with the migration plugin, I get the following deprecated messages


 == InstallSeed: seeding
2023-10-25 15:10:21 notice: 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.
/opt/openitc/frontend/vendor/cakephp/migrations/src/CakeAdapter.php, line: 83
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `vendor/cakephp/migrations/src/CakeAdapter.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only.
Trace:
/opt/openitc/frontend/vendor/cakephp/cakephp/src/Core/functions.php /opt/openitc/frontend/vendor/cakephp/cakephp/src/Core/functions.php, line 300
/opt/openitc/frontend/vendor/cakephp/cakephp/src/Database/Connection.php /opt/openitc/frontend/vendor/cakephp/cakephp/src/Database/Connection.php, line 506
Cake\Database\Connection->newQuery() /opt/openitc/frontend/vendor/cakephp/migrations/src/CakeAdapter.php, line 83
Migrations\CakeAdapter->getQueryBuilder() /opt/openitc/frontend/config/Seeds/InstallSeed.php, line 153
InstallSeed->run() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php, line 146
Phinx\Migration\Manager\Environment->executeSeed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php, line 420
Phinx\Migration\Manager->executeSeed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php, line 612
Phinx\Migration\Manager->seed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Console/Command/SeedRun.php, line 106
Phinx\Console\Command\SeedRun->execute() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php, line 37
Migrations\Command\Phinx\Seed->parentExecute() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/Phinx/Seed.php, line 76
Migrations\Command\Phinx\Seed->execute() /opt/openitc/frontend/vendor/symfony/console/Command/Command.php, line 326
Symfony\Component\Console\Command\Command->run() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 1063
Symfony\Component\Console\Application->doRunCommand() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 320
Symfony\Component\Console\Application->doRun() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 174
Symfony\Component\Console\Application->run() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/MigrationsCommand.php, line 126
Migrations\Command\MigrationsCommand->execute() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/BaseCommand.php, line 190
Cake\Console\BaseCommand->run() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/MigrationsCommand.php, line 198
Migrations\Command\MigrationsCommand->run() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 334
Cake\Console\CommandRunner->runCommand() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 172
Cake\Console\CommandRunner->run() /opt/openitc/frontend/bin/cake.php, line 12
[main]

deprecated: 16384 :: 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.
/opt/openitc/frontend/vendor/cakephp/migrations/src/CakeAdapter.php, line: 83
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `vendor/cakephp/migrations/src/CakeAdapter.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only. on line 300 of /opt/openitc/frontend/vendor/cakephp/cakephp/src/Core/functions.php
Stack Trace:

/opt/openitc/frontend/vendor/cakephp/cakephp/src/Core/functions.php /opt/openitc/frontend/vendor/cakephp/cakephp/src/Core/functions.php, line 300
/opt/openitc/frontend/vendor/cakephp/cakephp/src/Database/Connection.php /opt/openitc/frontend/vendor/cakephp/cakephp/src/Database/Connection.php, line 506
Cake\Database\Connection->newQuery() /opt/openitc/frontend/vendor/cakephp/migrations/src/CakeAdapter.php, line 83
Migrations\CakeAdapter->getQueryBuilder() /opt/openitc/frontend/config/Seeds/InstallSeed.php, line 153
InstallSeed->run() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php, line 146
Phinx\Migration\Manager\Environment->executeSeed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php, line 420
Phinx\Migration\Manager->executeSeed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php, line 612
Phinx\Migration\Manager->seed() /opt/openitc/frontend/vendor/robmorgan/phinx/src/Phinx/Console/Command/SeedRun.php, line 106
Phinx\Console\Command\SeedRun->execute() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php, line 37
Migrations\Command\Phinx\Seed->parentExecute() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/Phinx/Seed.php, line 76
Migrations\Command\Phinx\Seed->execute() /opt/openitc/frontend/vendor/symfony/console/Command/Command.php, line 326
Symfony\Component\Console\Command\Command->run() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 1063
Symfony\Component\Console\Application->doRunCommand() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 320
Symfony\Component\Console\Application->doRun() /opt/openitc/frontend/vendor/symfony/console/Application.php, line 174
Symfony\Component\Console\Application->run() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/MigrationsCommand.php, line 126
Migrations\Command\MigrationsCommand->execute() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/BaseCommand.php, line 190
Cake\Console\BaseCommand->run() /opt/openitc/frontend/vendor/cakephp/migrations/src/Command/MigrationsCommand.php, line 198
Migrations\Command\MigrationsCommand->run() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 334
Cake\Console\CommandRunner->runCommand() /opt/openitc/frontend/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 172
Cake\Console\CommandRunner->run() /opt/openitc/frontend/bin/cake.php, line 12
[main]
 == InstallSeed: seeded 0.7359s

This is /opt/openitc/frontend/config/Seeds/InstallSeed.php, line 153:

<?php

$QueryBuilder = $this->getAdapter()->getQueryBuilder();   // line 153

$stm = $QueryBuilder->select('*')
    ->from($table->getName())
    ->where([
        'plugin' => $record['plugin'],
        'task'   => $record['task']
    ])
    ->execute();
    $result = $stm->fetchAll();

    if (empty($result)) {
         $table->insert($record)->save();
    }

Expected Behavior

No deprecated messages

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

No branches or pull requests

2 participants