backdrop-contrib / coder_upgrade

Helps automate some/most of the work required to upgrade a module from Drupal to Backdrop 1.x
GNU General Public License v2.0
4 stars 7 forks source link

PHP Fatal error: Class 'SearchApiAbstractService' not found #59

Closed robertgarrigos closed 2 years ago

robertgarrigos commented 3 years ago

I got this error when trying to run a code upgrade:

Class 'SearchApiAbstractService' not found

Although this is triggered by the metatag module (https://github.com/backdrop-contrib/metatag/issues/64) - even if it's not turned on - I just deleted the offending class in metatag_search_test.module to bypass this error.

bugfolder commented 2 years ago

As noted above (and in this issue https://github.com/backdrop-contrib/metatag/issues/34), it's triggered by metatag module when search_api module isn't present.

The root cause seems to be that coder_upgrade is trying to run module_load_include() on all modules, including disabled modules. So even though the metatag_search_test module is disabled, it's being loaded, which leads to the problem in the declaration

class MetatagSearchTestSearchApiService extends SearchApiAbstractService { ... }

This is happening specifically in file begin.inc, in these two functions:

/**
 * Caches the theme registry from core files (including disabled modules).
 */
function coder_upgrade_cache_theme_registry() {
  global $_coder_upgrade_theme_registry;
...

which calls

/**
 * Builds theme registry for disabled core modules.
 *
 * Adapted from _theme_build_registry().
 *
 * @return unknown_type
 */
function coder_upgrade_theme_build_registry() {
  // Get the list of disabled core modules.
  $list = coder_upgrade_module_list(TRUE, 0);
...

From the code comments, it appears that including disabled modules was intentional (not sure why?). But perhaps it wasn't intentional to include disabled contrib modules, only core? Further investigation needed.

bugfolder commented 2 years ago

Found it. It's a bug in coder_upgrade_module_list(). PR to follow.

bugfolder commented 2 years ago

The problem was in a query in function coder_upgrade_module_list(), which is a residue from D8. As written, the function assumed that core modules live in modules/. But in Backdrop, they live in core/.

bugfolder commented 2 years ago

@docwilmot, do you want to check this PR before I merge it (and make a new bugfix release)?