-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Create migration for session table when pdo handler is used #48059
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
[HttpFoundation] Create migration for session table when pdo handler is used #48059
Conversation
f8cb980
to
734cf60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but should go to 2.8.x. And should be merged only after upstream PR is merged.
/edit: Ah sorry, I intended to write this comment in doctrine-bundle (and I can't delete this comment now)
src/Symfony/Bridge/Doctrine/SchemaListener/PdoSessionHandlerSchemaSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
Outdated
Show resolved
Hide resolved
aad3487
to
ee96111
Compare
ee96111
to
c312553
Compare
c312553
to
ac62915
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I force-pushed some changes here and on doctrine/DoctrineBundle#1569
Once this PR is ready, we'll have to do the same for the lock component :)
]; | ||
} | ||
|
||
protected function getIsSameDatabaseChecker(Connection $connection): \Closure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When integrating a component with doctrine migrations, we want to known whether the database used by doctrine is the same as the one used by the component. In e.g. Messenger, this can be done by comparing the connection objects for identity, but in cases where several connections are used (eg session / lock use a different connection), then this doesn't work.
This method implements this check by creating a temporary table: if the component's connection can drop this table, then we're on the same db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Thank you 🙏
ac62915
to
f95d882
Compare
3cdc426
to
a62248e
Compare
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
Show resolved
Hide resolved
a62248e
to
04e7960
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransport.php
Show resolved
Hide resolved
04e7960
to
aebdc58
Compare
Thanks @alli83 for working on this feature, this is much appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
…rSchemaSubscriber (alli83) This PR was merged into the 6.3 branch. Discussion ---------- [HttpFoundation] inject SessionHandler in PdoSessionHandlerSchemaSubscriber | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT | Doc PR | I'm working on it following the PR #48059. In #48059, it works only if you put the handler explicitly to PdoSessionHandler in the configuration (handler_id) but it stops working if the session is defined by the factory and we can't use it as follow: ```` handler_id: '%env(resolve:DATABASE_URL)%' ````` Linked to DoctrineBundle PR doctrine/DoctrineBundle#1623 Also imho, I think the second argument of configureSchema inPdoSessionHandler should be optional and set to return true if not defined since the function is public eg. one wants to add the table to the Schema. Commits ------- 9aded06 [HttpFoundation] inject SessionHandler in PdoSessionHandlerSchemaSubscriber
…rSchemaSubscriber (alli83) This PR was merged into the 6.3 branch. Discussion ---------- [HttpFoundation] inject SessionHandler in PdoSessionHandlerSchemaSubscriber | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT | Doc PR | I'm working on it following the PR symfony/symfony#48059. In symfony/symfony#48059, it works only if you put the handler explicitly to PdoSessionHandler in the configuration (handler_id) but it stops working if the session is defined by the factory and we can't use it as follow: ```` handler_id: '%env(resolve:DATABASE_URL)%' ````` Linked to DoctrineBundle PR doctrine/DoctrineBundle#1623 Also imho, I think the second argument of configureSchema inPdoSessionHandler should be optional and set to return true if not defined since the function is public eg. one wants to add the table to the Schema. Commits ------- 9aded06c0c [HttpFoundation] inject SessionHandler in PdoSessionHandlerSchemaSubscriber
…ndler::configureSchema() (nicolas-grekas) This PR was merged into the 6.3 branch. Discussion ---------- [HttpFoundation] Fix defining expiry index in PdoSessionHandler::configureSchema() | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Forgotten in #48059 Commits ------- 1a67728 [HttpFoundation] Fix defining expiry index in PdoSessionHandler::configureSchema()
…d update tests (alli83) This PR was merged into the 6.3 branch. Discussion ---------- [DoctrineBridge] add missing UPGRADE notes for #50689 and update tests | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | | License | MIT | Doc PR | `$isSameDatabase` parameter was introduced in #48059. It has been added in order to know whether the database used by doctrine is the same as the one used by the component when integrating the latter with doctrine migrations. Also related to #50689 Commits ------- 5d2817d [DoctrineBridge] add missing UPGRADE notes for #50689
…eDatabase arg… (alli83) This PR was merged into the 6.3 branch. Discussion ---------- [DoctrineBridge] add missing changelog mention for isSameDatabase arg… | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | $isSameDatabase parameter was introduced in #48059. It has been added in order to know whether the database used by doctrine is the same as the one used by the component when integrating the latter with doctrine migrations. Also related to #50699 (UPGRADE mention) and #50689 Commits ------- 208861a [DoctrineBridge] add missing changelog mention for isSameDatabase arg introduced in #48059
* 6.3: [DoctrineBridge] add missing changelog mention for isSameDatabase arg introduced in #48059 Bump Symfony version to 6.3.2 Update VERSION for 6.3.1 Update CHANGELOG for 6.3.1 Bump Symfony version to 6.2.13 Update VERSION for 6.2.12 Update CHANGELOG for 6.2.12 Bump Symfony version to 5.4.26 Update VERSION for 5.4.25 Update CONTRIBUTORS for 5.4.25 Update CHANGELOG for 5.4.25
* 6.4: [DoctrineBridge] add missing changelog mention for isSameDatabase arg introduced in #48059 [DependencyInjection] Skip scanning scalar values in compiler passes when not needed Bump Symfony version to 6.3.2 Update VERSION for 6.3.1 Update CHANGELOG for 6.3.1 Bump Symfony version to 6.2.13 Update VERSION for 6.2.12 Update CHANGELOG for 6.2.12 Bump Symfony version to 5.4.26 Update VERSION for 5.4.25 Update CONTRIBUTORS for 5.4.25 Update CHANGELOG for 5.4.25
… $isSameDatabase to configureSchema() methods (alli83) This PR was merged into the 7.0 branch. Discussion ---------- [Cache][DoctrineBridge][Lock][Messenger] Add parameter $isSameDatabase to configureSchema() methods | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | $isSameDatabase parameter was introduced in #48059. This PR aims to remove BC layer on configureSchema method and $isSameDatabase parameter This parameter has been added in UPGRADE-6.3 in #50699 Commits ------- 7a8a8bf [DoctrineBridge]rm BC layer configureSchema check database
The purpose of this PR is to automatically generate the session table with the make migration command in addition to https://symfony.com/doc/current/session/database.html#preparing-the-database-to-store-sessions
Even though
WellKnownSchemaFilterPass
is deprecated, atm the session table is blacklisted by theWellKnownSchemaFilterPass
, that's why I need to set the SchemaAssetFilter to null.todo: