Make AI Related Content compatible with Search API 1.40
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3555867. -->
Reported by: [keiserjb](https://www.drupal.org/user/3518715)
Related to !9
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Fatal error after updating Search API to 8.x-1.40: undefined function _search_api_views_find_field_alias() in ai_related_content_views_data_alter().</p>
<p>Error: Call to undefined function _search_api_views_find_field_alias()<br>
in ai_related_content_views_data_alter()<br>
(line 23 of modules/contrib/ai_related_content/ai_related_content.module)</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Steps to Reproduce</p>
<p>Install or update Search API to 8.x-1.40.</p>
<p>Enable AI Related Content.</p>
<p>Rebuild caches (drush cr) or navigate to /admin/config/search/search-api.</p>
<p>Observe fatal error.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Replace the call to _search_api_views_find_field_alias() with a local helper that searches the $data array for a matching 'real field' key.<br>
This avoids using private helpers and works across all Search API versions.</p>
<h3>Root Cause</h3>
<p>The module calls the private helper function _search_api_views_find_field_alias() from Search API’s Views integration inside hook_views_data_alter().<br>
As of Search API 8.x-1.40, the project refactored its procedural hooks into OOP-based hook implementations (aca35bc3 — “Switched to OOP hook implementations”), which changed the load timing or removal of that private helper.</p>
<p>Since this function is not part of Search API’s public API, it is no longer available when ai_related_content_views_data_alter() executes.</p>
issue