When installing Drupal using a non-English language the installation fails after the language selection submit with the following error:
Call to a member function has() on a non-object in /Users/erik/www/drupal8/core/includes/bootstrap.inc on line 902

Steps to reproduce:

  1. Check out core 8.x
  2. Create a translations directory: sites/default/files/translations (or sites/mysite/files/translations if you are using an existing sandbox)
  3. Download the Dutch 7.17 core translation into this directory
  4. Start the installation the usual way (example.com/install.php)
  5. Select 'Nederlands' as language
  6. 'Save an continue'

This error may be related to #1849004: One Service Container To Rule Them All and #1849700: DrupalKernel's container.modules param should contain module filenames, not full namespace paths. It did not exist before the first was committed, and the latter repaired the installation process work for English.

commit 761ac679064e50650e663d562fb5270714818ca4
Author: catch <catch@35733.no-reply.drupal.org>
Date:   Thu Nov 29 20:26:37 2012 +0000

    Issue #1849004 by chx, xjm: One Service Container To Rule Them All.
commit 522188692156731724b59bcfc06207b5b0d1e3ec
Author: catch <catch@35733.no-reply.drupal.org>
Date:   Mon Dec 3 17:20:24 2012 +0000

    Issue #1849700 by katbailey, effulgentsia: Fixed DrupalKernel's container.modules param should contain m

This issue is blocking my work on #1848490: Import translations automatically during installation.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

effulgentsia’s picture

What's happening is that st() is called very early in the install process, by Drupal\Core\Database\Install\Tasks::runTestQuery().

But, in the presence of installing from a translation, st() calls:
- drupal_get_path() which calls drupal_get_filename() which expects drupal_container() to already exist, but it doesn't yet.
- Even if you fix the above with ($container = drupal_container()) && $container->has(...), you then run into a problem that st() also calls Gettext::filesToArray() which calls PoStreamReader::open() which calls drupal_realpath() which requires various subsystems to already be bootstrapped in order to deal with file stream wrappers.

So, I'm guessing we need to either make runTestQuery() not call st(), or else fix st() to not invoke these various functions when this early in the install process.

chx’s picture

Converting runTestQuery to format_string is quite probably quick and easy. It's a whole another question whether we are happy with the nontranslateability of those strings. I think fixing the whole path is better. ($container = drupal_container()) && $container->has(...), is something I wanted to do anyways and

> PoStreamReader::open() which calls drupal_realpath()

Well that looks a particularly bad idea to me, didnt we say to call drupal_realpath only in utmost need? I recall there was an issue saying so. Did it not make into the docs? Looking at the code, fopen(drupal_realpath($this->_uri), 'rb'); wtf is that and why you can't do fopen($this->_uri, 'rb'); ??? fopen supports wrappers just fine.

effulgentsia’s picture

Status: Active » Needs review
FileSize
1.39 KB

Let's see what bot thinks. The drupal_realpath() was added in #1658842: Introduce a translations:// stream wrapper to access the .po file directory. I added a comment there linking to here.

YesCT’s picture

Issue tags: +D8MI
chx’s picture

Issue tags: +Novice

Now we just need someone to manually test the scenario described in #0 and we are good to go. That is a very easy thing to do because of the high quality report Sutharsan filed so I tag this step Novice. If it fixes the problem , please RTBC.

YesCT’s picture

without the patch:

sudo rm -r sites
git checkout sites
drush -y sql-drop --db-url="mysql://root:root@localhost/d8-patch"
git pull --rebase
git reset --hard
mkdir sites/default/files
mkdir sites/default/files/translations
cd sites/default/files/translations
curl -O http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.17.nl.po

1. pick nederlands
i-8-s01-2012-12-11_2321.png

2. see other language, proceed with install
i-s02-2012-12-11_2329.png

3. enter db info
i-8-s03-2012-12-11_2323.png

4. white screen
i-8-s04-whitescreen-2012-12-11_2324.png

I do not get the error "Call to a member function has() on a non-object in /Users/erik/www/drupal8/core/includes/bootstrap.inc on line 902"

but it does white screen!

test the patch

drush sql-drop
cd ../../../..
sudo rm -r sites
git checkout sites
git pull --rebase
git reset --hard
git checkout -b install-1864292-3
curl -O http://drupal.org/files/installer-mi.patch
git apply --index installer-mi.patch
git commit -m "3 patch"
mkdir sites/default/files
mkdir sites/default/files/translations
cd sites/default/files/translations
curl -O http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.17.nl.po

steps are the same as without the patch for 1. 2. 3.

4. Get different error
at core/install.php?langcode=nl&profile=standard

In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.

Failed to CREATE a test table on your database server with the command CREATE TABLE {drupal_install_test} (id int NULL). The server reports the following message: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drupal_install_test' already exists: CREATE TABLE {drupal_install_test} (id int NULL); Array ( ) .

Are you sure the configured username has the necessary permissions to create tables in the database?

i-s04-2012-12-11_2330.png

Next

hmm. test again: maybe a totally new everything? git clone and a new db too?

YesCT’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
87.24 KB
38.63 KB

the drush sql-drop I did to test the patch did not drop the tables.

repeated with
drush -y sql-drop --db-url="mysql://root:root@localhost/d8-patch"
and verified the db was empty

install goes same as without the patch for 1. 2. 3.

Then 4. proceeds
i-s04b-noerror-2012-12-11_2352.png

5. goes to 100% and then warning
at
core/install.php?langcode=nl&profile=standard

Warning: Invalid argument supplied for foreach() in locale_translation_status_delete_languages() (line 949 of core/modules/locale/locale.module).

i-s05-warning-2012-12-12_0008.png

6. install finishes ok.

So manual test result: patch gets the install past the white screen.

Sutharsan’s picture

Patch tests fine with me too. Code looks sane. Thanks for the quick response!

effulgentsia’s picture

In #1658842-61: Introduce a translations:// stream wrapper to access the .po file directory, looks like the drupal_realpath() was added because of suspected PHP versions / OS not supporting stream wrappers directly, but PHP's documentation of fopen() states that it supports stream wrappers. So, given that, and the testing above, RTBC.

[Edit: oops, I didn't notice this was already RTBC'd earlier. Thanks!]

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Committed/pushed to 8.x.

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