Drupal – Rebuilding Node Access Via Drush in Windows

January 9, 2017

So this one is pretty simple, but I’m not ashamed to say I spent too much time struggling to figure out why this wasn’t working. Rebuilding the node access via the website kept resulting in the website timing out, so instead of tweaking the max execution time and other things like that in order to get it going I figured we should be able to run the command through Drush. A quick Google told me this was possible, and that the command was:

drush php-eval 'node_access_rebuild()'

So I ran the command, no errors or any feedback was given but it appeared to have worked correctly. The only issue was that it seemed too darn fast, rebuilding the node access on a large site should take some time, not one second. So after a little testing I confirmed it did not work and went back to the drawing board.

Eventually I stumbled upon the answer, in Windows the command is slightly different and uses double quotes instead of single quotes. So if you are running Drupal and Drush within a windows server, you’ll want to run the command as follows:

drush php-eval "node_access_rebuild()"

As usual, the solution is simple once you know the answer 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.