-
Notifications
You must be signed in to change notification settings - Fork 26
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
MNT Handle DatabaseExceptions thrown by PHP 8.1 #311
MNT Handle DatabaseExceptions thrown by PHP 8.1 #311
Conversation
f5220e7
to
24c4d72
Compare
I don't think this actually solves the problem - users are going to get different behaviour depending on what database version is used which is not good. |
dddcdd6
to
248faa7
Compare
Changed solution, this matches behavior to PHP < 8.1 |
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.
Adds some extra DB queries which isn't great but since you've closed my PR I guess we'll have to go with this approach lol
One small thing to fix.
src/PageTypes/DatedUpdateHolder.php
Outdated
strpos($e->getMessage(), 'Incorrect DATETIME value') !== false | ||
) { | ||
$controller->getRequest()->getSession()->set(DatedUpdateHolderController::TEMP_FORM_MESSAGE, _t( | ||
__CLASS__ . '.InvalidDateFormat', |
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.
__CLASS__ . '.InvalidDateFormat', | |
DatedUpdateHolderController::class . '.InvalidDateFormat', |
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.
Updated
248faa7
to
d14cf42
Compare
PHP 8.1 set the MySQLi default error mode to exceptions https://php.watch/versions/8.1/mysqli-error-mode
This resulted in https://github.com/silverstripe/cwp/runs/7351123074?check_suite_focus=true
It would have been nice to just add
| DatabaseException
tocwp/src/PageTypes/DatedUpdateHolderController.php
Line 178 in 192a902
However the failing FunctionalTest (which makes an HTTP request to the frontend) simply doesn't go through this bit of code.