php-pm / php-pm-drupal

Drupal adapter for use of Drupal 8 with PHP-PM
43 stars 2 forks source link

Allow multiple passes in \Drupal\Core\DrupalKernel::setSitePath() #2

Closed kentr closed 8 years ago

kentr commented 8 years ago

The PHP-PM architecture appears to be calling \Drupal\Core\DrupalKernel::setSitePath() multiple times. The method has a guard which prevents subsequent calls after the kernel is "booted", which is causing an exception; it needs to allow subsequent calls while still disallowing changes to sitePath.

I'm not keen on hacking core, but until a better solution is found I'm proposing patching:

  public function setSitePath($path) {
    if ($this->booted) {
      throw new \LogicException('Site path cannot be changed after calling boot()');
    }
    $this->sitePath = $path;
  }

to:

  public function setSitePath($path) {
    if ($this->booted && $path !== $this->sitePath) {
      throw new \LogicException('Site path cannot be changed after calling boot()');
    }
    $this->sitePath = $path;
  }
kentr commented 8 years ago

The patch is in kentr-allow-repeated-setSitePath-in-DrupalKernel.patch

kentr commented 8 years ago

Resolved with patch mentioned above.

kentr commented 7 years ago

Added patch in Allow repeated calls to DrupalKernel ::setSitePath() on d.o

andypost commented 5 years ago

https://www.drupal.org/project/drupal/issues/2829346 commited in 8.4.x