Skip to content
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

FIX Don't throw exception for bad dates with mysql 8.0 #312

Conversation

GuySartorelli
Copy link
Member

Follow-up from #310
Fixes https://github.com/silverstripe/recipe-solr-search/runs/7352246945?check_suite_focus=true

Bit of an odd fix as it does add API, but I think that's unavoidable in this situation.

Parent issue

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this honestly feels like we're hacking in some ugly code just to fix a unit test

@@ -66,6 +67,7 @@ public function testInvalidDateFormat()
*/
private function isRunningMySQL()
{
return strpos(strtolower(get_class(DB::get_connector())), 'mysql') !== false;
$connector = DB::get_connector();
return strpos(strtolower(get_class($connector)), 'mysql') !== false || $connector instanceof PDOConnector;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think postgres can also run PDO? (we don't test this in our matrix though)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm that's a good point... since we don't have postgres PDO in our matrix I think I'd prefer to keep this change - the likelyhood of someone running this test with postgres PDO is very unlikely (and they can find a better way to do this if they want to) - but for now we do have mysql PDO tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so how come strpos(strtolower(get_class(DB::get_connector())), 'mysql') isn't working? What does DB::get_connector() return with mysql pdo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PDO connector class is literally PDOConnector (the full namespaced class name is checked of course, so SilverStripe\ORM\Connect\PDOConnector)
So it's a mysql db, but the connector class name doesn't hint at that at all.

* The request has had an error that can result in a DB exception
* if filtering by the dates provided.
*/
public function requestHasBadDates(): bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New API, would need to target 2 so doesn't work in terms of fixing the unit test on the previous branch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general for normal circumstances I'd agree. But I don't think this is going to cause any problems for anyone, and it will fix this bug.

I think we either need to accept that this is not how we normally treat semver, but since it won't break anything it's fine, or target to 2 and merge there, and accept that anything earlier will not pass in CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you can think of a way to do this without adding the new method?
Would marking it internal help resolve any trepidation?

@GuySartorelli
Copy link
Member Author

feels like we're hacking in some ugly code just to fix a unit test

It's not just the test though. The test is correctly failing, because the functionality is broken. This PR aims to fix the broken functionality.

@emteknetnz
Copy link
Member

Closing in favor of #311

@emteknetnz emteknetnz closed this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants