mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
BasicEntityPersister getInsertSQL() wrong value in openswoole #7150
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PsmaDev on GitHub (May 17, 2023).
/** * {@inheritDoc} */ public function getInsertSQL() { if ($this->insertSql !== null) { return $this->insertSql; }This "if" brtoke down stateles in case of using openswoole.
In case of changing table prefix this check return wrong sql if multiple requests for tables with different prefix:
https://www.doctrine-project.org/projects/doctrine-orm/en/2.15/cookbook/sql-table-prefixes.html
The easiest fix just remove this 3 lines:
if ($this->insertSql !== null) { return $this->insertSql; }@derrabus commented on GitHub (May 17, 2023):
I'm really sorry, but I don't understand your request. Can you elaborate a bit more on…
@PsmaDev commented on GitHub (May 17, 2023):
Openswoole is not dying after each request like php-fpm. So first request $this->insertSql is null and it generated, next request $this->insertSql is not null so it will be same like in 1 request, but script changed table prefix, so new insert is neede.
INSERT INTO prefix1_tablename ...
INSERT INTO prefix2_tablename ...
In traditional php this is not problem, each request bootstraping from scratch.
Possible add some check if table name for entity changed, just set it null.
Or make this "cache" optional.
Now it is not possible to keep it stateless in long term app.
@beberlei commented on GitHub (May 17, 2023):
This has nothing to do with openswoole however, changing the table prefix within a request and then using the EntityManager will produce the same problem. It is not supported to change the table prefix after the EntityManager was created.
The listener that you link doesn't even show support for changing the prefix, its created at ctor time and then the listener is passed to EventManager before the EntityManager is created.