Closed tabacco closed 9 years ago
Just an update to confirm I can still reproduce this in hhvm 2.4.2
Thanks for reporting this. Feel free to submit a PR if you (or someone else reading this) gets to this before we do.
An isolated repro for this would be great and help get this addressed. (We're not familiar with FuelPHP and it's not something we're testing at the moment, CC: @JoelMarcey)
I doubt it's within my skillset to fix and submit a PR, but I'll at least try to get you a repro case in the next couple of days.
Do you still have this issue with HHVM 3? If so, could you also try the nightlies.
Confirmed it's still happening in 3.1 - looks like you don't build nightlies for Saucy, so I'll have to get a Trusty VM going later this weekend to try it out. I also still owe you guys a test case, which I'll try to do this weekend as well.
Thanks - 3.1 wasn't out when I last commented; it's fairly unlikely we've fixed it in master since then, so don't worry too much about the nightlies.
An isolated test case would still greatly help :)
Sample app that exhibits the issue: https://www.dropbox.com/s/l4teuxo4ofxiu7p/hhvm_2011_repro.tar.gz
Steps to set up:
php oil refine migrate:current
Alternatively, if you prefer to skip the migration portion, you can just do:
CREATE TABLE `demos` (
`id` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Let me know if that works for you. Sorry it's complicated with the database setup, but since the issue is in the framework's db code I couldn't think of a better way. The fuel orm doesn't support sqlite yet, unfortunately.
@tabacco I was also confronted with the same problem on FuelPHP1.7.1 and I've fixed the connection.php source as below.
$instance = static::$instances[$name];
return $instance;
HHVM seems working well so far.
@Crux-One what did the code look like before when it didn't work? Can you make a small test case?
@ptarjan I'm guessing he's referring to https://github.com/fuel/core/blob/1.7/master/classes/database/connection.php#L85 as it's the one quoted in the error in my earlier comment.
The original line is:
return static::$instances[$name];
I can try and confirm the fix tomorrow in the test case I posted earlier. I can also try to make a smaller test case this weekend.
I am getting this error too. But the fix posted by @Crux-One and @tabacco doesnt seem to be working for me, the ERROR is still on line 65 not 85 for me
Invalid operand type was used: Invalid type used as key in fuel/core/classes/database/connection.php on line 65
@yswery It was working fine for me before reboot HHVM I guess, then just suddenly I have reproduced a bug. That is incorrect solution that I have posted.
@tabacco @Crux-One Is there any way to ferret out a small, reproducible test case from Fuel (that optimally doesn't depend on Fuel) that can be used to track this problem down?
After spending lots of time with this I found that FuelPHP runs though this function twice on initialisation.
first time round the input param $name is null and will get set as a string mostly "default" but on the second iteration it will be passing a full object as $name as seen below:
string(7) "default"
object(Fuel\Core\Database_PDO_Connection)#118 (8) {
["_connection":protected]=>
NULL
["_identifier":protected]=>
string(1) "`"
["_db_type"]=>
string(0) ""
["last_query"]=>
NULL
["_instance":protected]=>
string(7) "default"
["_in_transaction":protected]=>
bool(false)
["_transaction_depth":protected]=>
int(0)
["_config":protected]=>
array(9) {
["type"]=>
string(3) "pdo"
["connection"]=>
array(5) {
["persistent"]=>
bool(false)
["compress"]=>
bool(false)
["dsn"]=>
string(31) "mysql:host=localhost;dbname=website"
["username"]=>
string(4) "root"
["password"]=>
string(8) "password"
}
["identifier"]=>
string(1) "`"
["table_prefix"]=>
string(0) ""
["charset"]=>
string(4) "utf8"
["collation"]=>
bool(false)
["enable_cache"]=>
bool(true)
["profiling"]=>
bool(false)
["readonly"]=>
bool(false)
}
}
to get this I put a var_dump() just before line 65 (where things go wrong.
so I assume things go wrong when we pass a full object to the static array in this scenario.
I quick hack and fix for this case is to add a line just before line 64 on fuel/core/classes/database/connection.php
settype($name, 'string');
converting the object into a string. this seemed have fixed it for me.
@tabacco Hi! Reading through this, I am not sure if this is an HHVM issue still or if it was a FuelPHP bug that was fixed by @yswery. Can you confirm? Thanks.
Closing due to inactivity.
I'm seeing a weird set of errors from my site running in a vagrant vm under hhvm. I haven't done any tweaking of the hhvm configs, it's just a stock install of hhvm-fastcgi in place of php-fpm.
This is FuelPHP 1.7.1 (the latest version) and hhvm 2.4.1 (from the official packages for Ubuntu 12.04).
The weird part is that the site works perfectly for about the first 10-20 requests (the actual number varies), then I start getting 500s and these errors start appearing in the logs:
By way of rough debugging, I added a var_dump and exit there and confirmed that the argument was in fact an array. That also exposed some earlier E_WARNINGs from the framework:
In all of these cases I confirmed that $name was the string "default".
I can 'fix' the error by restarting hhvm-fastcgi, then reproduce it again by just refreshing any page that does database access until it starts failing. Pages that don't do database access continue to work fine.
Please let me know if there's any other info I can get you that might be helpful!