Commerce - access denied on checkout page When I tried to access the checkout page I get "Access denied"; this happens with every role, all of which have permission to view the cart/make orders/view orders.

This happens even with a complete fresh install of Commerce Kickstart.  There must be something going on with the server configuration?  All other admin and user functions work without any issue.  I am using HHVM instead of standard PHP, but surely I am not the first one to attempt to run Drupal Commerce on HHVM.  I can find no trace of this issue elsewhere except someone with the same question 6 months ago that was unresolved.

Any idea what's going on here?
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.