Hello,

I love this "module". Saved me many times on my drupal 7 sites. Mostly on test sites where I'm screwing around, but still!

I have a question that might expose me as incredibly ignorant or might just have a simple answer: How do I rebuild the registry and remove extra entries in Drupal 6? Does the dtools WSOD "module" do that?

Feel free to answer abruptly and mark this as "Fixed/stupid" :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

Title: Backport/Drupal 6? » Backport to Drupal 6 (or make generic drush command)
Category: support » feature

On D6 all that really happens is that the paths in the system table get messed up. You can manually fix the ones that are broken (and blocking you from bootstrapping) and get past that, then do a cache clear or visit the modules page for the rest.

A backport to D6 should be pretty easy; really the drush command ought to go into drush itself and be sensitive to whether it just has to do the system table or also the class registry (D7).

rfay’s picture

Status: Active » Needs review
FileSize
1.97 KB

The key need in D6 is to rebuild the module cache.

In the bad old days, drush could accidentally download a copy of Drupal into sites/all/modules (or this could happen some other way) and then drush updatedb would make all those system modules get put into the system table. *Then* the poor user discovered it and deleted sites/all/modules/drupal... and their site came to a grinding halt.

So drush rr with this patch on d6 now will solve this, but there's one problem.

Although we have

  define('MAINTENANCE_MODE', 'update');

in there to prevent hook_init() from being invoked, it is not actually being set in time to prevent hook_init(). I can't figure out what the magic is to do that. It's actually pretty important, and could be the cause of some of the #fails we have occasionally seen (feeds?). I think because we aren't setting that in time, hook_init() is happening... and hitting some fail.

jonhattan’s picture

Perhaps it works if bootstrap is postponed untill the define is done ?

1. in the command definition

'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap.

2. in the command callback

define('MAINTENANCE_MODE', 'update');
if (!drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_DATABASE)) {
  return drush_set_error('DRUPAL_SITE_NOT_FOUND', dt('You need to specify an alias or run this command within a drupal site.'));
}

this kind of "soft-bootstrap" is also done in command core-directory.

rfay’s picture

Thanks so much! I look forward to trying this out.

rfay’s picture

Status: Needs review » Needs work
FileSize
2.87 KB

@jonhattan I very much appreciate your help. More? :-)

I haven't gotten hook_init() not to fire. Here is with watchdogs in hook_init, and with the attached patch, which specifies bootstrap as you suggested. Note that hook_init() still gets invoked before the command is ever called.

$ drush rr -v
Initialized Drupal 6.23-dev root directory at                           [notice]
/home/rfay/workspace/d6git
Initialized Drupal site default at sites/default                        [notice]
WD core: Invoking hook_init()                                           [notice]
WD admin_menu: In admin_menu_init                                       [notice]
In admin_menu_init                                                   [status]
drush_registry_rebuild about to bootstrap                               [notice]
menu_rebuild() in DRUSH_BOOTSTRAP_DRUPAL_DATABASE.                      [notice]
Module cache has been rebuilt.                                          [notice]
Bootstrapping to DRUPAL_BOOTSTRAP_FULL.                                 [notice]
Command dispatch complete                                               [notice]
jonhattan’s picture

There's a bootstrap error, not printed in any way, generated by drush_enforce_requirement_core($command); in drush.php:

Array
(
    [DRUSH_COMMAND_CORE_VERSION_ERROR] => Command registry-rebuild requires Drupal core version 6+ to run.
)

This is probably an incongruence in drush:

+    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap.
+    'core' => array('6+'),

In DRUSH_BOOTSTRAP_DRUSH phase, drush can't fullfill the 'core' requirement. So get rid of 'core' requirement and you're done :)

rfay’s picture

Status: Needs work » Needs review
FileSize
3.28 KB

Ding Ding Ding! @jonhattan wins the prize. Thanks!

This seems to work fine for D6, and I think it will resolve some D7/8 problems as well.

jonhattan’s picture

Status: Needs review » Reviewed & tested by the community

Havent tested it but looks good. Perhaps it worth testing drush @alias rr

rfay’s picture

Status: Reviewed & tested by the community » Fixed

Committed with one additional detail: A quick TRUNCATE {cache} before the registry rebuild, which fixes #1324000: Failed to rebuild registry on PDO Exception: duplicate entry and #1366094: CTools breaks the registry rebuild

http://drupalcode.org/project/registry_rebuild.git/commitdiff/047af8f

This is now in the dev release; I'd appreciate any test results

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.