- Issue created by @drunken monkey
- Merge request !278Resolve #3542808 "Add variants of plugin getters to our entity classes that don’t throw exceptions" → (Merged) created by drunken monkey
- Status changed to Fixed
12 days ago 8:34am 31 October 2025
Currently, we have a lot of code that does something like the following:
if ($index->hasValidTracker()) {
return $index->getTrackerInstance()->…();
}
While this will never throw an exception (or only in extreme edge cases), IDEs still complain about an unchecked exception because getTrackerInstance() is documented to throw an exception if the plugin could not be loaded. As a consequence, it is sometimes impossible to write clean code using the Search API without including unnecessary try/catch constructs.
Add variants like getTrackerInstanceIfAvailable() that return NULL instead of throwing an exception and use that where appropriate.
Active
1.0
Framework