[11.x] Fix PHP 8.5 deprecation warning for PDO::MYSQL_ATTR_SSL_CA#539
Open
emmadesilva wants to merge 1 commit into
Open
[11.x] Fix PHP 8.5 deprecation warning for PDO::MYSQL_ATTR_SSL_CA#539emmadesilva wants to merge 1 commit into
PDO::MYSQL_ATTR_SSL_CA#539emmadesilva wants to merge 1 commit into
Conversation
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR patches a deprecation warning triggered when using PHP 8.5 with Laravel Zero 11.x.
I understand that Laravel Zero 11 may not be officially supported anymore, but since a lot of projects are still running it, this minor patch would provide a lot of value with minimal downside.
See tie in PR laravel-zero/foundation#133
Background:
In PHP 8.5, the global
PDO::MYSQL_ATTR_SSL_CAconstant was deprecated in favor of the namespacedPdo\Mysql::ATTR_SSL_CA. However, because Laravel Zero 11.x must maintain compatibility with PHP 8.2 and 8.3 (where thePdo\Mysqlclass does not exist), we cannot simply swap the constant without causing a fatal error in older environments.The Fix:
This PR updates the MySQL and MariaDB connection configurations to use a conditional check:
(defined('Pdo\Mysql::ATTR_SSL_CA') ? Pdo\Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA)This dynamically applies the new constant for users on PHP 8.5+, while safely falling back to the legacy constant for users on PHP 8.2 - 8.4, completely resolving the deprecation notice without introducing breaking changes.
Related Issues
Checklist