Closed indesignlatam closed 4 years ago
It looks like the Carbon library actually doesn't support 'date'
: https://github.com/briannesbitt/Carbon/blob/c734a138a3a14314f516e08dc9951c33e37fa090/src/Carbon/Carbon.php#L546-L585
Do you have a more isolated example of different behavior between HHVM and PHP? Otherwise, it's not even clear this is an HHVM bug, as opposed to your code passing something into Carbon which it doesn't understand.
Im not very sure how to isolated it. I can use any guidance to do it.
Builder {#531 ▼
#query: Builder {#530 ▼
#cacheKey: null
#cacheMinutes: "1"
#cacheTags: null
#cacheDriver: null
#connection: MySqlConnection {#183 ▶}
#grammar: MySqlGrammar {#185 ▶}
#processor: MySqlProcessor {#186}
#bindings: array:6 [▼
"select" => []
"join" => []
"where" => array:2 [▼
0 => Carbon {#537 ▼
+"date": "2015-08-10 21:01:36.000000"
+"timezone_type": 3
+"timezone": "America/Bogota"
}
1 => 1
]
"having" => []
"order" => []
"union" => []
]
+aggregate: null
+columns: null
+distinct: false
+from: "listings"
+joins: null
+wheres: array:3 [▶]
+groups: null
+havings: null
+orders: array:2 [▶]
+limit: null
+offset: null
+unions: null
+unionLimit: null
+unionOffset: null
+unionOrders: null
+lock: null
#backups: []
#bindingBackups: []
#operators: array:26 [▶]
#useWritePdo: false
}
#model: Listing {#526 ▶}
#eagerLoad: array:2 [▶]
#macros: array:4 [▶]
#onDelete: Closure {#536 ▶}
#passthru: array:10 [▶]
}
This might be the serialized object, so this will cache successfully in php but not in HHVM
Same error :/ Any news ?
[2015-09-18 23:00:32] testing.ERROR: exception 'InvalidArgumentException' with message 'Unknown setter 'date'' in Carbon.php:583
Stack trace:
#0 (): Carbon\Carbon->__set()
#1 (): DateTime->__sleep()
In my case it was caused only when caching the Carbon object, so when i need the object to be cached i dont use Carbon.
Its not a the way it must be, but it works.
Is there any chance of this getting fixed, as our code which is fine on PHP is breaking on HHVM because of "Unknown setter 'date'" too.
@earnaway almost 0 chance without an isolated test case, i.e., one that doesn't depend on Carbon but exhibits the same root difference that causes the problem here. The only information we have so far is "something causes Carbon caching to fail under HHVM". The OSS team is super strapped for people right now (enough that I'm not even on the team any more and am just trying to pitch in when I can) -- this needs some legwork in figuring out where exactly the difference is between HHVM and PHP.
With such a test case... chances are still low, depending on the issue to be honest, but they aren't 0. And often times community members like fixing weird differences, depending on what the root issue ends up being, and the chances of a good PR being merged which fixes this are very high.
I'm no expert on the source code, but the issue seems to be in the way HHVM serialises the DateTime object.
During serialisation, the DateTime sleep method is called. It sets the "date" field in the object. This in turn seems to call the set method on the Carbon object (which inherits from DateTime) but "date" isn't a valid option for Carbon's __set method, and so the exception is thrown.
I don't really follow how PHP serialises its DateTime implementation, but the implementations between PHP and HHVM seem very different.
It does seem odd that such a low level method in HHVM is causing magic functions being executed at the PHP level. Not really sure if thats normal or not.
Weird and hacky solution to this:
This is what I've added at the src/Carbon/Carbon.php under the method __set.
/**
* Set a part of the Carbon object
*
* @param string $name
* @param string|int|\DateTimeZone $value
*
* @return string
* @throws \InvalidArgumentException
*/
public function __set($name, $value)
{
if(defined('HHVM_VERSION')){
return '';
}
switch ($name) {
// ...
}
}
Not sure if it affect other things, but it is my workaround for now.
More on this issue: https://laravel.io/forum/03-31-2015-cachecarbon-problem-under-hhvm
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.
This issue applies to running php code on hhvm. Hhvm nolonger supports running php code since hhvm version 4.0.0.
Hhvm has also removed the magic method __set()
in hhvm 4.56.0.
Im running an existing Laravel website and testing it on hhvm which i found increases performance in about 300% or 400% sometimes even more.
When using briannesbitt/Carbon in some point i get the following error:
Running hhvm version HipHop VM 3.8.1 (rel) Compiler: tags/HHVM-3.8.1-0-g3006bc45691762b5409fc3a510a43093968e9660 Repo schema: 253b3802ce1bcd19e378634342fc9c245ac76c33 Carbon version 1.2.0 Laravel 5.0