Skip to main content
added 611 characters in body
Source Link

On Ubuntu or Debian machines, if session.save_pathI found out that there is not set, then session files are saved in /var/lib/php5 by defaulta difference between how Zend and HHVM interprete the php key() function.

If you checkIn the hhvm logs in /var/log/hhvm/error.logDrupal commerce_checkout module there is a function that returns the first key of an errorarray by using the php key() function (commerce_checkout.module, line 480).

\nFatal error: Failed to initialize storage module: user (path: /var/lib/php5) in /var/www/html/commerce-demo/includes/session.inc on line 287

/**
 * Returns the page ID of the first checkout page sorted by weight.
 */
function commerce_checkout_first_checkout_page() {
  return key(commerce_checkout_pages());
}

Drupal/PHP fails to create a session in the drupal_session_start() function becauseOn the default location to storeZend rendering engine this returned the session files /var/lib/php5 does not exist ordesired result of the first array key. But in HHVM this returned nothing. I believe this is because the pointers of the array were not known within our setup with hhvmflushed by HHVM (maybe for performance reasons), and they were flushed in the Zend engine.

In my Drupal settings.php file I addeddon't think it was a good idea of the creaters of this module to use the bottomkey() function to get the first key of the array anyway

I now rewrote this function to this:

ini_set("session/**
 * Returns the page ID of the first checkout page sorted by weight.save_path", 
 ""*/
function commerce_checkout_first_checkout_page() {
 return reset(array_keys(commerce_checkout_pages()));
}

This resetsGetting the path to "" keys of the array first and then with reset(an empty string), by default this evaluates rewind the array's internal pointer to the temp folder offirst element and return the systemvalue of that first array element. This helped me: http://stackoverflow.com/questions/4927850/location-for-session-files-in-apache-php

To findOf course the current session save path, you can use session_save_path() key(Get and/or set the current session save path) function did the job on the standard Zend engine, but for HHVM this didn't.

Why drupal failedI will report this issue to create only the sessions related tomaintenance crew of the checkout page is not clear to medrupal commerce module, but nowand hopefully it works ;will be commited into the next release. I don't think there is anything wrong with the way HHVM interprets the key function (if I am right in thinking this is the root of the problem). I think the key() function just shouldn't be used like this in this situation.

On Ubuntu or Debian machines, if session.save_path is not set, then session files are saved in /var/lib/php5 by default.

If you check the hhvm logs in /var/log/hhvm/error.log there is an error

\nFatal error: Failed to initialize storage module: user (path: /var/lib/php5) in /var/www/html/commerce-demo/includes/session.inc on line 287

Drupal/PHP fails to create a session in the drupal_session_start() function because the default location to store the session files /var/lib/php5 does not exist or is not known within our setup with hhvm.

In my Drupal settings.php file I added to the bottom

ini_set("session.save_path", "");

This resets the path to "" (an empty string), by default this evaluates to the temp folder of the system. This helped me: http://stackoverflow.com/questions/4927850/location-for-session-files-in-apache-php

To find the current session save path, you can use session_save_path() (Get and/or set the current session save path).

Why drupal failed to create only the sessions related to the checkout page is not clear to me, but now it works ;)

I found out that there is a difference between how Zend and HHVM interprete the php key() function.

In the Drupal commerce_checkout module there is a function that returns the first key of an array by using the php key() function (commerce_checkout.module, line 480).

/**
 * Returns the page ID of the first checkout page sorted by weight.
 */
function commerce_checkout_first_checkout_page() {
  return key(commerce_checkout_pages());
}

On the default Zend rendering engine this returned the desired result of the first array key. But in HHVM this returned nothing. I believe this is because the pointers of the array were not flushed by HHVM (maybe for performance reasons), and they were flushed in the Zend engine.

I don't think it was a good idea of the creaters of this module to use the key() function to get the first key of the array anyway

I now rewrote this function to this:

/**
 * Returns the page ID of the first checkout page sorted by weight. 
 */
function commerce_checkout_first_checkout_page() {
 return reset(array_keys(commerce_checkout_pages()));
}

Getting the keys of the array first and then with reset() rewind the array's internal pointer to the first element and return the value of that first array element. Of course the key() function did the job on the standard Zend engine, but for HHVM this didn't.

I will report this issue to the maintenance crew of the drupal commerce module, and hopefully it will be commited into the next release. I don't think there is anything wrong with the way HHVM interprets the key function (if I am right in thinking this is the root of the problem). I think the key() function just shouldn't be used like this in this situation.

Source Link

On Ubuntu or Debian machines, if session.save_path is not set, then session files are saved in /var/lib/php5 by default.

If you check the hhvm logs in /var/log/hhvm/error.log there is an error

\nFatal error: Failed to initialize storage module: user (path: /var/lib/php5) in /var/www/html/commerce-demo/includes/session.inc on line 287

Drupal/PHP fails to create a session in the drupal_session_start() function because the default location to store the session files /var/lib/php5 does not exist or is not known within our setup with hhvm.

In my Drupal settings.php file I added to the bottom

ini_set("session.save_path", "");

This resets the path to "" (an empty string), by default this evaluates to the temp folder of the system. This helped me: http://stackoverflow.com/questions/4927850/location-for-session-files-in-apache-php

To find the current session save path, you can use session_save_path() (Get and/or set the current session save path).

Why drupal failed to create only the sessions related to the checkout page is not clear to me, but now it works ;)