Add variants of plugin getters to our entity classes that don’t throw exceptions

Created on 24 August 2025, 16 days ago

Problem/Motivation

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.

Proposed resolution

Add variants like getTrackerInstanceIfAvailable() that return NULL instead of throwing an exception and use that where appropriate.

📌 Task
Status

Active

Version

1.0

Component

Framework

Created by

🇦🇹Austria drunken monkey Vienna, Austria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024