Drush cc all and other non-web tools can't clear MTimeProtected directories because of file perms. See #1899842-8: MTimeProtected Directory Grief.

Patch forthcoming.

CommentFileSizeAuthor
#1 container_rebuild.patch2.27 KBmoshe weitzman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Active » Needs review
FileSize
2.27 KB

As promised.

Fabianx’s picture

+++ b/core/lib/Drupal/Core/DrupalKernel.phpundefined
@@ -288,20 +289,33 @@ protected function initializeContainer() {
+        // Rebuild if container is dirty. Used by CLI scripts such as Drush.
+        $dirty = $this->container->get('state')->get('container.rebuild');
+        if ($dirty && $this->allowDumping) {
+          $this->container->get('state')->set('container.rebuild', FALSE);

I am not sure that the allowDumping is not only a flag that is set.

I would directly check the filesystem service like done in dumpContainer if things are writable. (as pasted in IRC - can't find the log atm.)

pounard’s picture

Does this mean one extra SQL query per page or did I misread the issue?

State API might be useful but for a so low level stuff it seems dangerous (framework not fully bootstrapped, how am I sure the k/v store is fully init yet?) and overkill.(once again one more SQL query, and there's already a lot of gratuitous k/v access during normal runtime).

moshe weitzman’s picture

For default installs, it would be an extra query. Sites that want to optimize that can choose a key/value for state system. An alternate state driver might choose to do one DB query for all data in state. We don't use it too much so that seems feasible to me.

By definition this code only works once the container exists so I'm assuming that state() is available.

Can you suggest an alternate approach?

pounard’s picture

No, sadly I can't, I just wanted to point out that out. Using a service for rebuilding the service container seemed a bit wonky to me.

Damien Tournoud’s picture

Running command line tools under a different user then the web server is asking for trouble sooner rather then later.

I don't see how this is different then any other permission issues you are going to bump into in that case. It feels like we are trying to workaround a server/environment configuration issue here.

pounard’s picture

I fully agree with #6, it's not really Drupal's code's cross to bear.

moshe weitzman’s picture

Status: Needs review » Postponed

For the moment, Drush is going to pursue a different strategy which is to write a patch to let folks optionally open up their MTime directories by making a settings.php modification. We'll open this back up if that effort is not fruitful. No issue to link to just yet.

chx’s picture

I always thought we will cache some of state... maybe.

pounard’s picture

@#9 This would be a great thing to do indeed.

Berdir’s picture

It would be an even better thing if you'd all review my patch #1786490: Add caching to the state system :)

dawehner’s picture

Issue summary: View changes
Status: Postponed » Fixed

The original issue:

Drush cc all and other non-web tools can't clear MTimeProtected directories because of file perms.

Is no longer an issue with using the cache subsystem for the container.

On top of that, I thought its always recommended to run drush with the webserver user.

Status: Fixed » Closed (fixed)

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