Node access rebuilds have a hard time limit
I thought I'd call attention to a bit of little-known Drupal trivia. The node_access_rebuild()
function has a hard-coded 240-second time limit. That means that attempting to rebuild the node_access
table with a tool like drush
probably won't work on a large site. Having a time limit helps keep the site from hitting memory limits and crashing.
In case you think you can out-smart the problem with time limit removal trickery, I think you'll find that the limit is deeply embedded in Drupal's core code. These drush
attempts will fail:
drush php-eval 'set_time_limit(0); node_access_rebuild();'drush php-eval 'ini_set("max_execution_time", 0); node_access_rebuild();'
The node_access_rebuild()
function also allows an argument to toggle batch mode, the intended design to bypass the 240 second limit. Trying that with drush
probably won't get the results you're hoping for, either.
drush php-eval 'node_access_rebuld(TRUE);'
Don't expect htop
to show a bunch of busy threads after running that. A web browser trumps drush
when it comes to performing successive HTTP requests for batch mode here.
Instead try telling Drupal that node access controls need a rebuild.
drush php-eval 'node_access_needs_rebuild(TRUE);'
or
drush vset node_access_needs_rebuild 1
After the rebuild status is set, any of the administration pages will show a link with an error message to prompt administrators to rebuild node permissions.
The link in the prompt goes to admin/reports/status/rebuild
, which will prompt with a confirmation form before actually rebuilding permissions.
Your next option is a bit fancier, using a PHP script by shrop.
Run it like this:
time drush php-script rebuild-perms.php
If all that doesn't satisfy your needs, as it should, then hack core.
Hacking core is usually the wrong answer to any question. Nonetheless, here's a patch against Drupal 7.34.
Don't let the irony escape you - the comment before the drupal_set_time_limit()
actually says the limit attempts to "allocate enough time."
Post categories