Proposed resolution

Turns out having PHP variable 'OPEN_BASEDIR' set causes glob() to return FALSE instead of an empty array when it finds no files on its scan. Found this comment in PHP reference manual for glob():

"If you have open_basedir set in php.ini to limit which files php can execute, glob(...) will return false when there are no matching files. If open_basedir is not set, the very same code will return an empty array in the same situation."

See comments in #1. It proposes a solution if someone wants to follow up. If you don't need 'OPEN_BASEDIR', the solution is easy.

Original report by SIFRO

Hello,

i'm trying a fresh install of D8 to see if i can help, but i can't even go past the installation process.

After unpacking, at step 1/7 and 2/7 i get the following warnings:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).

Then, after entering mysql details and clicking on "proceed" (http://www.example.com/core/install.php?langcode=en&profile=standard&op=...), the fun ends with a fatal error :(

Fatal error: Call to undefined function theme() in /path/to/core/includes/install.core.inc on line 941

Comments

dags’s picture

The warning occurs because the method getComponentNames() attempts to iterate over the $files variable - but in some cases, that variables value is FALSE.

From InstallStorage.php lines 131-145. HEAD at b416a37.

public function getComponentNames($type, array $list) {
    $extension = '.' . $this->getFileExtension();
    $folders = array();
    foreach ($list as $name) {
      $directory = $this->getComponentFolder($type, $name);
      if (file_exists($directory)) {
        $files = glob($directory . '/*' . $extension);
        foreach ($files as $filename) {
          $name = basename($filename, $extension);
          $folders[$name] = $directory;
        }
      }
    }
    return $folders;
  }

According to the PHP docs, glob() is supposed to return an empty array if it doesn't find a matching file and should only return FALSE on error. I can't see why it's returning FALSE in this case but it does so when searching in the following directories, all of which contain no *.yml files:

core/modules/tour/config
core/modules/picture/config
core/modules/options/config
core/modules/field_sql_storage/config
core/modules/editor/config
core/modules/ckeditor/config
core/modules/block/config

To circumvent the warnings for now, change

$files = glob($directory . '/*' . $extension);

to

$files = glob($directory . '/*' . $extension) ?: array();

However, after doing that I ran into this seemingly unrelated error:

Fatal error: Call to undefined function theme() in /var/www/d8/core/includes/install.core.inc on line 947

Investigating that now...

dags’s picture

Turns out that undefined function theme() error message is a little misleading...

In install.core.inc, install_display_output($e->getMessage, $install_state) is called if an exception occurs while executing install_being_request($install_state) or install_run_tasks($install_state). The root error message is "The service definition "module_handler" does not exist."

larowlan’s picture

Do you have core.services.yml? There should be yml files in those folders above too.

dcrocks’s picture

I can't reproduce this, but those directories don't have any files in their config directory in a finished install, so it would seem best to focus on why glob() is returning false. It might help to know what environment this is occurring in. A note from the PHP manual about glob():

"If you have open_basedir set in php.ini to limit which files php can execute, glob(...) will return false when there are no matching files. If open_basedir is not set, the very same code will return an empty array in the same situation."

Sifro’s picture

UPDATE: after receiving the warning and the fatal error explained above, now if i try to go the homepage i get this:

Fatal error: Call to a member function get() on a non-object in /path/to/core/lib/Drupal.php on line 147

Of course i didn't expect it to work considering that the installation failed, but it might be an hint for someone.

I have really no idea of how to proceed.

Sifro’s picture

Regardin my env... these are the compile options:

'./configure' '--with-apxs2' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-pcre-regex=/usr/local' '--with-pdo-mysql=/usr' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-mbstring'

Loaded modules: core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_reqtimeout mod_include mod_filter mod_deflate mod_log_config mod_logio mod_env mod_expires mod_headers mod_unique_id mod_setenvif mod_version mod_proxy mod_proxy_connect mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_ajp mod_proxy_balancer mod_ssl prefork http_core mod_mime mod_dav mod_status mod_autoindex mod_asis mod_suexec mod_cgi mod_dav_fs mod_dav_lock mod_negotiation mod_dir mod_actions mod_userdir mod_alias mod_rewrite mod_so mod_cloudflare mod_php5

Open basedir: /home/myuser/:/tmp:/var/tmp:/usr/local/lib/php/
Safe Mode: OFF
Magic Quotes: OFF

Don't know if there are any other settings worth checking.

UPDATE: now i'm trying to download from the git repos instead of the alpha2 version on the website, and at the "verify requirements" step i get this:

Requirements problem
The service definition "request" does not exist.

It seems quite a common problem already addressed in the forums.

UPDATE 2: i managed to workaround the problem above, and ended up getting the same error at the same step

Fatal error: Call to undefined function theme() in /path/to/drupal/core/includes/install.core.inc on line 947

dags’s picture

I can't reproduce this, but those directories don't have any files in their config directory in a finished install, so it would seem best to focus on why glob() is returning false. It might help to know what environment this is occurring in. A note from the PHP manual about glob():

"If you have open_basedir set in php.ini to limit which files php can execute, glob(...) will return false when there are no matching files. If open_basedir is not set, the very same code will return an empty array in the same situation."

@dcrocks - spot on! I had forgot that I set the 'open_basedir' property when I was trying to get PHPStorm working with XDebug on my dev VM. I removed it and now those warnings disappear. I'm still having trouble installing against the most recent HEAD though... but at least 1 mystery is solved. Thanks!

dags’s picture

@Sifron,

The error: The service definition "request" does not exist. is most often caused because settings.php does not have write permissions. Make sure you check that. I was getting the undefined function theme() error too. I was able to work around it by adding require_once theme.inc somewhere in the bootstrap phase but I forget exactly where now (sorry, I know that doesn't help, I'll try to remember and update this post). Anyway, resolving that error didn't really help much as I eventually ended up with undefined function call get() on a non-object that you were getting too.

dcrocks’s picture

I don't know how often open_basedir is used or if it is documented as unsupported by drupal so a fix for that might still be in the cards. I've seen a number of errors in D8 install where the original error is deeply hidden(see #1987262: [Installation Error] Symfony: "The service definition 'request' does not exist."). Some of them trace back to permissions problems, others to database problems. Can you give more info on your install: OS, database, php version, etc.?

dags’s picture

Server
Ubuntu 12.04.1 server running in a VirtualBox VM using Vagrant.

Apache

Apache/2.2.22 (Ubuntu)

Loaded modules:
core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status



PHP

5.3.10-1ubuntu3.6 with Suhosin-Patch (built: Mar 11 2013 14:34:31)
Zend Engine v2.3.0, Xdebug v2.2.2

I haven't been making any drastic changes but I have been tinkering with Xdebug trying to get remote debugging working with PHPStorm which is running and is what is helping me debug these installation errors.



Database
I'm connecting to the Drupal 8 database through the root user. Here's the result of mysql status:

mysql  Ver 14.14 Distrib 5.5.28, for debian-linux-gnu (i686) using readline 6.2

Connection id:		1925
Current database:       d8
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.5.28-0ubuntu0.12.04.3-log (Ubuntu)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/var/run/mysqld/mysqld.sock

The errors I'm experiencing happen against the current HEAD of 8.x when performing a clean installation. These are the steps I follow, from the root dir:

  1. sudo git pull
  2. sudo rm -rf sites/default/files sites/default/settings.php
  3. sudo cp sites/default/default.settings.php sites/default/settings.php
  4. sudo mkdir sites/default/files
  5. sudo chmod 777 sites/default/files sites/default/settings.php
  6. visit http://d8.local/ and start install process

I'm tailing the PHP log with tail -f /var/log/php/error.log and I see this when visiting http://d8.local/. It's interesting because it says it's a fatal error yet installation continues uninterrupted. I don't see this error if I go directly to http://d8/core/install.php/.

[03-Jul-2013 14:32:34 UTC] PHP Fatal error:  Call to a member function get() on a non-object in /var/www/d8/core/lib/Drupal.php on line 222
[03-Jul-2013 14:32:34 UTC] PHP Stack trace:
[03-Jul-2013 14:32:34 UTC] PHP   1. _drupal_exception_handler($exception = *uninitialized*) /var/www/d8/core/includes/bootstrap.inc:0
[03-Jul-2013 14:32:34 UTC] PHP   2. _drupal_log_error($error = *uninitialized*, $fatal = *uninitialized*) /var/www/d8/core/includes/bootstrap.inc:1960
[03-Jul-2013 14:32:34 UTC] PHP   3. drupal_maintenance_theme() /var/www/d8/core/includes/errors.inc:187
[03-Jul-2013 14:32:34 UTC] PHP   4. _drupal_maintenance_theme() /var/www/d8/core/includes/bootstrap.inc:2365
[03-Jul-2013 14:32:34 UTC] PHP   5. Drupal::config($name = *uninitialized*) /var/www/d8/core/includes/theme.maintenance.inc:57

Then I continue on with the installation process and get through entering in the Database information and that's where things go down... On my most recent attempt, I'm getting this error, which I've never seen before:

Database configuration

The service definition "feed.bridge.reader" does not exist.

UPDATE:
After seeing the above error message, I refreshed the page and installation continued. I moved on to another task but when I came back I saw the admin setup screen with this error message at the top:

Notice: Use of undefined constant USERNAME_MAX_LENGTH - assumed 'USERNAME_MAX_LENGTH' in _install_configure_form() (line 2408 of core/includes/install.core.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_form_process_password_confirm' not found or invalid function name in form_builder() (line 1905 of core/includes/form.inc).

I filled out the fields, clicked continue, and was given message that Drupal was already installed. I clicked view site and got a 324 (net::ERR_EMPTY_RESPONSE). This was in /var/log/php/error.log:

[03-Jul-2013 15:47:12 UTC] PHP Fatal error:  Call to undefined function user_validate_name() in /var/www/d8/core/includes/install.core.inc on line 2492
[03-Jul-2013 15:47:12 UTC] PHP Stack trace:
[03-Jul-2013 15:47:12 UTC] PHP   1. {main}() /var/www/d8/core/install.php:0
[03-Jul-2013 15:47:12 UTC] PHP   2. install_drupal() /var/www/d8/core/install.php:39
[03-Jul-2013 15:47:12 UTC] PHP   3. install_run_tasks() /var/www/d8/core/includes/install.core.inc:93
[03-Jul-2013 15:47:12 UTC] PHP   4. install_run_task() /var/www/d8/core/includes/install.core.inc:531
[03-Jul-2013 15:47:12 UTC] PHP   5. drupal_build_form() /var/www/d8/core/includes/install.core.inc:581
[03-Jul-2013 15:47:12 UTC] PHP   6. drupal_process_form() /var/www/d8/core/includes/form.inc:419
[03-Jul-2013 15:47:12 UTC] PHP   7. drupal_validate_form() /var/www/d8/core/includes/form.inc:920
[03-Jul-2013 15:47:12 UTC] PHP   8. _form_validate() /var/www/d8/core/includes/form.inc:1212
[03-Jul-2013 15:47:12 UTC] PHP   9. form_execute_handlers() /var/www/d8/core/includes/form.inc:1485
[03-Jul-2013 15:47:12 UTC] PHP  10. call_user_func_array() /var/www/d8/core/includes/form.inc:1565
[03-Jul-2013 15:47:12 UTC] PHP  11. install_configure_form_validate() /var/www/d8/core/includes/form.inc:1565
Sifro’s picture

So, to summarize...

CentOS with directadmin.
PHP 5.3.24
Apache/2.2.24
Mysql Ver 14.14 Distrib 5.5.27, for Linux (x86_64) using readline 5.1

'./configure' '--with-apxs2' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-pcre-regex=/usr/local' '--with-pdo-mysql=/usr' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-mbstring'

Loaded modules: core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_reqtimeout mod_include mod_filter mod_deflate mod_log_config mod_logio mod_env mod_expires mod_headers mod_unique_id mod_setenvif mod_version mod_proxy mod_proxy_connect mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_ajp mod_proxy_balancer mod_ssl prefork http_core mod_mime mod_dav mod_status mod_autoindex mod_asis mod_suexec mod_cgi mod_dav_fs mod_dav_lock mod_negotiation mod_dir mod_actions mod_userdir mod_alias mod_rewrite mod_so mod_cloudflare mod_php5

Open basedir: /home/myuser/:/tmp:/var/tmp:/usr/local/lib/php/
Safe Mode: OFF
Magic Quotes: OFF

Steps to reproduce:

- unpack d8 (either from .tar.gz or git pull)
- immediatly get this warning:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Config\InstallStorage->getComponentNames() (line 138 of core/lib/Drupal/Core/Config/InstallStorage.php).

- if i don't set proper permissions, i also get the error outlined here: #1987262: [Installation Error] Symfony: "The service definition 'request' does not exist."

- enter my mysql details, click on "proceed", and get a fatal error:

Fatal error: Call to undefined function theme() in /path/to/core/includes/install.core.inc on line 941

- go to the homepage and get another fatal:

Fatal error: Call to a member function get() on a non-object in /path/to/core/lib/Drupal.php on line 147

@dags: At a certain point, while trying to investigate the issue, i got the "service definition "feed.bridge.reader" does not exist" error too, but sorry, i don't remember the exact steps i took.

dcrocks’s picture

We know why you get the error in getComponentName. Could you either reset 'open_basedir' in your PHP settings or make the change suggested in #1 so that doesn't confuse the issue? It may be contributing to later errors.

Sifro’s picture

Indeed setting open_basedir off solves all the problems for me after a fresh install.

dcrocks’s picture

That's great. Solving problems during install can be very painful in my experience.

Sifro’s picture

Status: Active » Closed (fixed)

i'm marking this issue as solved, even if probably the fact that drupal doesn't work with open_basedir ON is not a good thing i guess.

dcrocks’s picture

Issue summary: View changes

hiding personal data

dcrocks’s picture

Title: Can't install Drupal 8 » OPEN_BASEDIR set causes drupal 8 install fail

Changed the title to better reflect the situation. Maybe someone will notice. Also updated issue summary.

Sifro’s picture

Status: Closed (fixed) » Active

ok, in this case it should be also in Active status.

longwave’s picture

There is already an issue for deciding what to do about open_basedir at #2019911: Add install requirement that open_basedir = Off since 8.x currently doesn't support it

dcrocks’s picture

Status: Active » Closed (duplicate)
dcrocks’s picture

Issue summary: View changes

Updating summary