we use Docker and Symfony 5.6, PHP 8.0, xcaddy v2.7.3 and MariaDB 10.3.34 with Doctrine. The application is divided into cron, caddy, node, php, db, db-backup and mailer containers.
The problem occures when creating any new entity and trying to save it to the database. Deleting entities works fine. The exact error message is:
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ at line 1
. It's thrown in
vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php`
The missing (
at the start of '?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' at line 1
is extremely interesting to me as a normal query might look more like this: 'INSERT INTO article (id, description, name, deletaed_at) VALUES (?, ?, ?, ?)'
Alas I’m stumped because we don’t modify flush()
and haven’t had any recent database migrations. We can connect to the databases (dev & live) without a hitch otherwise (e.g. getting the data, deleting, PhpStorm view).
The latest change has been updating xcaddy from 2.6.4 to 2.72. After noticing the error to 2.73 and then 2.6.4 again but it persists.
I don’t know if it’s related but bin/console doctrine:schema:validate
returns no warnings or errors.
When stepping through the process with a debugger, the entity itself exists with all its data. Fields and values are assessed correctly. A connection to the database in the code can be established.
All the other posts concerning SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ...
seem to be handwritten queries or contain reserved column names so I currently see no way to apply their solutions. Any help would be appreciated.
Edit: a past commit from 3rd of June works, and the docker compose build with data from that day works with our current master commit, so I’ll keep climbing commits until it doesn’t work anymore.
After running composer update
there have been changes in
vendor/bin/doctrine
,vendor/bin/doctrine-dbal
,vendor/bin/doctrine-migrations
,vendor/bin/path-type-declarations
,vendor/bin/php-parse
,vendor/bin/simple-phpunit
,vendor/bin/var-dump-server
andvendor/bin/yaml-lint
But the only changes in each file are a switch from
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'ComposerBinProxyWrapper'))
) {
include("phpvfscomposer://" . __DIR__ . '/..'.'/doctrine/orm/bin/doctrine');
exit(0);
}
}
include __DIR__ . '/..'.'/doctrine/orm/bin/doctrine';
to
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'ComposerBinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/doctrine/orm/bin/doctrine');
}
}
return include __DIR__ . '/..'.'/doctrine/orm/bin/doctrine';
Edit:
The error happens for many entities but the setup is usually like this. Thank you, I’ll look for a way to get the query
public function addArticle(Request $request): Response
{
$data = json_decode($request->getContent(), null, 512, JSON_THROW_ON_ERROR);
if (!isset($data->id)) {
throw new BadRequestException('No id was given');
}
$masterArticle = $this->masterArticleRepository->find($data->id);
if (!$masterArticle) {
throw $this->createNotFoundException();
}
$period = $this->getPeriod($request);
$periodArticle = new PeriodArticle($masterArticle, $period);
$this->entityManager->persist($periodArticle);
$this->entityManager->flush();
return new JsonResponse($this->serializer->normalize($periodArticle, 'json', ['groups' => 'medium']));
}
Edit: @aynber, @hakre the query is INSERT INTO region_attribute (description, combination, additional_description, internal_note, agency_note, sales_agency_note, do_not_show, active_pictures, promotion_price, special_price, special_description, payback, new_in_assortment, give_away, recommendation, deleted_at, region_id, master_article_id, master_mix_group_id, master_container_id, period_article_id, period_mix_group_id, period_container_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
params and types are empty arrays
EDIT: about the time caddy got updated, we updated the composer.lock
as well. In there have been many changes concerning doctrine. Building the application with the composer.lock of the previous day isn’t a clean solution but it will be our fix until we find out what exactly needs to be changed to work with the new versions.
2
Answers
thank you for your help.
The problem isn't caddy, as has been reviewed, but lies in the version upgrades concerning doctrine in our composer.lock and that is a problem we can only solve on our own, so I'm closing the question.
You are missing the code that substitutes values into the question mark placeholders. Let’s see the PHP code with the "execute" and "bind" (or whatever syntac is needed for Symphony/doctrine).