9

I've truncated registry table, because of the other problems, but now I have problem rebuilding the registry table based on the files listed in the database.

I'm calling registry_update(), _registry_update() or registry_rebuild() to do it:

drush eval "registry_rebuild();"

But then I've the following error which appears:

Fatal error: Class 'SelectQueryExtender' not found in includes/pager.inc on line 15

By default (on system module install) registry table is empty, so how Drupal fills that table with the proper default data?

15

The absolutely easiest way to do it, is to enable any module, as that will do it for you. Of course, if you need to rebuild the registry, generally speaking the UI might be unavailable, but drush en [modulename] might be all you need.

If that's not enough, Registry rebuild makes it trivially easy to rebuild the registry. The easiest way to do it, is to install it as a drush extension.

Install the extension, and run drush rr.

The module page has detailed installation instructions and also shows how to run it without drush if necessary.

9

This can be fixed either by reinstalling Drupal or by copying the table from an ideally fresh installation of Drupal into your broken instance.

Or you can try the following workaround (only do it when your Drupal instance is already broken):

  1. Backup the old registry table first (just in case):

    drush sqlq "CREATE TABLE registry_bak LIKE registry; INSERT INTO registry_bak SELECT * FROM registry;"
    drush sqlq "CREATE TABLE system_bak LIKE system; INSERT INTO system_bak SELECT * FROM system;"
    
  2. Clear the bootstrap cache and registry table.

    drush sqlq "TRUNCATE cache_bootstrap; TRUNCATE registry"
    
  3. Insert the basic data into registry table:

    drush sqlq 'INSERT INTO registry (name, type, filename) VALUES ("SelectQueryExtender", "class", "includes/database/select.inc"), ("DrupalDefaultEntityController", "class", "includes/entity.inc");'
    drush eval "registry_update();"
    
  4. Clear the caches:

    drush -y cc all
    
  5. If clear caches in 4. failed, because of some other missing classes, you can either:

    a) Add the missing classes manually, in example:

    $ drush -y cc all
    Fatal error: Class 'Entity' not found in profile2.module on line 593
    $ grep -Rwl "^class Entity" .
    ./sites/all/modules/entity/includes/entity.inc
    $ drush sqlq 'INSERT INTO registry (name, type, filename) VALUES ("Entity", "class", "sites/all/modules/entity/includes/entity.inc");'
    $ drush -y cc all # testing...
    # If Fatal error:, repeat 5a. again.
    

    or:

    b) Try to disable these failing contrib modules (e.g. profile2, rules) by:

    drush sqlq 'UPDATE system SET status = 0 WHERE name = "failing_module"'
    

    and repeat the steps starting from 4.

  6. If something is more broken than it was, you can restore your tables to the original point (which was done in 1. step) by:

    drush sqlq "TRUNCATE registry; INSERT INTO registry SELECT * FROM registry_bak;"
    drush sqlq "TRUNCATE system; INSERT INTO system SELECT * FROM system_bak;"
    

    and try again.

See also: How to move installed modules from /sites/all/modules/* to /sites/all/contrib/modules/*


Rebuilding registry table can be also achieved by the following script ran in Drupal webroot:

grep -ERo "^(\s+)?(abstract )?class (\S+)" . | tr ':' ' ' | sed "s/abstract //g" | awk '{print "INSERT INTO registry (filename, type, name) VALUES (\x27"$1"\x27,\x27"$2"\x27,\x27"$3"\x27);"}' | $(drush sql-connect) -f

Thanks to Mike's help with regex.

  • 4
    thx - step 3 saved me where drush rr failed – ErichBSchulz May 1 '15 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.