This commit of #1497230: Use Dependency Injection to handle object definitions to core breaks the ability for Drush to bootstrap Drupal.

# drush status
PHP Fatal error:  Class 'Symfony\Component\DependencyInjection\ContainerBuilder' not found in  /home/ubuntu/drupal/core/includes/bootstrap.inc on line 2335
PHP Fatal error:  Class 'Symfony\Component\DependencyInjection\ContainerBuilder' not found in /home/ubuntu/drupal/core/includes/bootstrap.inc on line 2335
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lotyrin’s picture

Issue summary: View changes

Add link to commitlog

lotyrin’s picture

Status: Active » Postponed (maintainer needs more info)

Might be a core bug.

tim.plunkett’s picture

Just a note, the RTBC patch in #1497230-128: Use Dependency Injection to handle object definitions does not resolve this.

tim.plunkett’s picture

Status: Postponed (maintainer needs more info) » Active
clemens.tolboom’s picture

Status: Active » Needs review
FileSize
720 bytes

Drush expects the t function to be available to early. Attached a quick patch which makes drush run again.

Guess this needs an overhaul by moving some logic into drush_bootstrap?

clemens.tolboom’s picture

Status: Needs review » Needs work

Never trust ones IDE ... netbean output looked ok :(

clemens.tolboom’s picture

Status: Needs work » Needs review
neclimdul’s picture

Status: Needs review » Needs work
+++ b/includes/output.incundefined
@@ -135,7 +135,14 @@ function drush_format($input, $label = NULL, $format = NULL) {
+  if ($drupal_t && drush_drupal_version() >= 8) {
+    // Is bootsprocess far enough
+    $loader = drupal_classloader();
+    $drupal_t = count($loader->getNamespaces()) > 0;
+  }
+
+  if ($drupal_t) {
     return t($string, $args);
   }
   else {

"Is bootsprocess"? do you mean bootstrap? Also missing trailing period.

Seems like a weird block of code but I can't think of something better ATM.

effulgentsia’s picture

+++ b/includes/output.inc
@@ -135,7 +135,14 @@ function drush_format($input, $label = NULL, $format = NULL) {
+    $loader = drupal_classloader();

There's an @todo in drupal_classloader() about cleaning some stuff up, but for now, it calls variable_get(), so we shouldn't call it if we haven't even bootstrapped to DRUPAL_BOOTSTRAP_CONFIGURATION, which we haven't in this case, cause once you bootstrap to that, the classloader also contains the namespace registrations.

Perhaps the test here could simply be drush_drupal_version() >= 8 && drupal_get_bootstrap_phase() >= DRUPAL_BOOTSTRAP_CONFIGURATION rather than testing the loader directly?

ZenDoodles’s picture

Rolled a patch... I assumed
function_exists('theme') was also to determine the level of bootstrap. I don't think this is the *best* solution, but it works as a temporary fix.

ZenDoodles’s picture

Status: Needs work » Needs review

Oops. Forgot to change status...

lyricnz’s picture

I have no idea about this Symphony stuff, but the patch in #9 fixes the

Fatal error: Class 'Symfony\Component\DependencyInjection\ContainerBuilder' not found in /Users/me/htdocs/drupal8/core/includes/bootstrap.inc on line 2351

clemens.tolboom’s picture

Status: Needs review » Needs work
+++ b/includes/output.inc
@@ -135,8 +135,11 @@ function drush_format($input, $label = NULL, $format = NULL) {
-  if (function_exists('t') && (drush_drupal_version() >= 7 || function_exists('theme'))) {
-    return t($string, $args);
+  if (function_exists('t')) {

This probably breaks on Drupal 6.

clemens.tolboom’s picture

I re-added the theme function check for Drupal 6.

clemens.tolboom’s picture

Title: Update Drush for #1497230 » Harned drush calling t() for D8 dependency injection construct.
Status: Needs work » Needs review

I was still puzzled why we do not use a get_t construct? Checking the get_t() code that will not work as get_t/8 is not checking a for valid t function which is weird.

I think we should file a bug report against core about this but need some feedback on that.
[edit]
Is the comment true? That is 'Is drush while bootstrapping not in need for either st() or t() function' depending on the drush command. (sorry for the noise ... I'm working on core #1189184: OOP & PSR-0-ify gettext .po file parsing and generation ;-)

function get_t() {
  static $t;
  // This is not converted to drupal_static because there is no point in
  // resetting this as it can not change in the course of a request.
  if (!isset($t)) {

[/edit]

Anyway patch needs review.

neclimdul’s picture

I would have just tossed a call to drupal_classload() earlier in the drush bootstrap because eventually more then t() is going to need it.

clemens.tolboom’s picture

@neclimdul calling drupal_classload() seems like the wrong solution to me.

eventually more then t() is going to need it

I personally think Drupal core is in err by having a 'bad' t function available. We now patch drush for that :(

What do you think?

moshe weitzman’s picture

Status: Needs review » Closed (duplicate)
tim.plunkett’s picture

This was marked as a dupe of an issue marked won't fix. Can you point to the exact core issue where this is being worked on?

ZenDoodles’s picture

Title: Harned drush calling t() for D8 dependency injection construct. » Drush calling t() before D8 dependency injection construct is available

Let's call it #1541990: Improve check before calling t() (D8 drupal_container() patch broke drush) @tim.plunkett since that's the one Sun reopened when I attempted a patch for core in [1590182]. I'm throwing my hands in the air on this issue. Will just continue to run drush with the patch in #9 above (which works for me on Drupal 6 too btw)...

ZenDoodles’s picture

Issue summary: View changes

Better link for commitlog