yii2: Fatal error: Error when compiled in HHVM

What steps will reproduce the problem?

Compile my yii2 project by command:

INDEX_TMP="/var/run/hhvm/fileindex"

find /var/www/html -name \*.php > $INDEX_TMP

hhvm --hphp -t hhbc -v AllVolatile=true --input-list $INDEX_TMP --output-dir /var/run/hhvm/

Yii2 throw an exception in class Session.php

private function setCookieParamsInternal()
    {
        $data = $this->getCookieParams();
        extract($data); // failed
        if (isset($lifetime, $path, $domain, $secure, $httponly)) {
            session_set_cookie_params($lifetime, $path, $domain, $secure, $httponly);
        } else {
            throw new InvalidParamException('Please make sure cookieParams contains these elements: lifetime, path, domain, secure and httponly.');
        }
    }

What is the expected result?

Run yii2 application after compiled code by hhvm

What do you get instead?

extract() functions can’t run in hhvm compiled. Link to issue: Fatal error: Could not create variable environment (repo mode only)

Additional info

Q A
Yii version 2.0.9
PHP version 7.0.8
Operating system Centos 7

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (20 by maintainers)

Most upvoted comments

22a224d232f23502bc2bfa3afce38dd337513b5a

I can not imagive the way to emulate extract() behavior.

Although, I can:

foreach ($array as $key => $value) {
    $$key = $value;
}

However, I am unsure if it work on HHVM either.

@thanhpv-h9 is talking about compiling code for HHVM. So far we’ve checked VM-runtime version.

it works in runtime but fails compiling.

I’ve verified that HHVM compiles project after my patch, but did not verified that it failed before.

Verified on Ubunty 14.04 with

# hhvm --version
HipHop VM 3.11.1 (rel)
Compiler: 3.11.1+dfsg-1ubuntu1
Repo schema: 2f678922fc70b326c82e56bedc2fc106c2faca61

Commit is reverted eb02b36

@thanhpv-h9 can you check if @klimov-paul solution works?

Seems it’s not going to be fixed in HHVM. Am I right?