-
Notifications
You must be signed in to change notification settings - Fork 822
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
NEW: Add method to check if a class is ready for db queries. #10276
base: 4
Are you sure you want to change the base?
NEW: Add method to check if a class is ready for db queries. #10276
Conversation
This effectively makes the functionality from Security::database_is_ready() reusable for any arbitrary DataObject subclass.
While I can see the value in this, we already have a bunch of method doing this in different way: silverstripe/silverstripe-graphql#445 (comment) I would rather have a some agreement on the best way to do it and make sure our code base is updated to use the correct approach everywhere. silverstripe/silverstripe-graphql#445 (comment) |
Makes sense. How do we go about doing that? I gather that the RFC process is unrefined at best.... |
I don't think we need an RFC for this. Maybe create a parent issue and details some of the places where we need this functionality and some of the approaches we've taken in the past. Maybe document clearly why this is needed as well. Addressing the problem will probably involved implementing the best approach,moving away from using the bad approaches and deprecating a bunch of methods. |
Added a parent issue. |
Not useful for technical debt that doesn't call into the database with the ORM to early in a request boot in a project I am not a part of :-) In all seriousness though +1 for this. |
*/ | ||
public function tableIsReadyForClass(string $class): bool | ||
{ | ||
if (!is_subclass_of($class, DataObject::class)) { |
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.
if (!is_subclass_of($class, DataObject::class)) { | |
// Bail if there's no active database connection yet | |
if (!DB::connection_attempted() || !DB::is_active()) { | |
return false; | |
} | |
if (!is_subclass_of($class, DataObject::class)) { |
This effectively makes the functionality from
Security::database_is_ready()
reusable for any arbitraryDataObject
subclass.
Replaces #10041
Parent issue