Author |
Message |
eithe
Joined: 14 Mar 2012 Posts: 3
|
Posted: Wed Mar 14, 2012 5:43 pm Post subject: foreach($this) problem |
|
|
Hi there,
While implementing a website using ioncube we've encountered a segmentation (11) fault, which, as I've managed to track it, was cause by one of the classes. Oddly enough, when substituting the class with unencrypted version of it everything was working fine. As the entire class had to be encrypted I've tracked which line of code was causing it, and here I am.
When iterating through $this, as
Code: | foreach($this as $key => $value)
unset($this->{$key}); |
a segmentation fault occurs.
Substituting such line with one that does the very same thing:
Code: | $keys = array_keys(get_object_vars($this));
foreach($keys as $key)
if (!empty($key))
unset($this->{$key}); |
solves the problem. (Another oddity - there needs to be an if (!empty($key)) check - even though there are no empty keys on that object! How can there be?)
I've tried to replicate the problem without using our classes, in this code:
Code: | <?php
class A
{
public $a = 'a';
public function delete()
{
foreach($this as $key => $value)
unset($this->{$key});
}
}
$a = new A();
$a->delete();
var_dump($a);
?> |
as such this will return, correctly:
Code: | object(A)#1 (0) { } |
However, the same, encrypted code will yield NULL, which I assume causes the domino effect.
PHP version: 5.2.14
ioncube loader version: 3.1.28
ioncube encoder is, I think, version: 6.5
OS: Red Hat 4.1.2
If this is error has been solved somewhere, I'll appreciate the link, though I've searched the forum, but couldn't find anything similar.
If required I can provide further information - cheers for any help!
--
edit: fixed an inconsistency in the example |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Fri Mar 16, 2012 11:08 am Post subject: |
|
|
Hi
Thanks for the example. The first observation is that you do have a very old Loader from the 3.1 series, which was followed by the 3.3 series and now series 4 Loaders. We tried using the 6.5 Encoder and version 7 Encoder with a version 3.3.20 Loader and also the current Loader, and couldn't reproduce. The code also works with our upcoming Loader for PHP 5.4. So using an updated Loader should resolve for you. _________________ Community Admin |
|
Back to top |
|
 |
eithe
Joined: 14 Mar 2012 Posts: 3
|
Posted: Mon Mar 19, 2012 4:23 pm Post subject: |
|
|
Cheers Nick - that's a response I was hoping for. Sadly, I'm not in charge of hosting, but I can pass the word along  |
|
Back to top |
|
 |
eithe
Joined: 14 Mar 2012 Posts: 3
|
Posted: Tue Mar 27, 2012 4:23 pm Post subject: ivirmfo chophysical |
|
|
Hi again!
The loader version has been updated to new one (4.0) and it's still producing same results, even with this example. I can provide an encoded file if you need it (though don't know if it will be any helpful).
edit: I've checked the encoded output on two servers - our clients and ours (both output NULL). The loader version differ though, but we want to definitely have it working on clients server  |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Sat Mar 31, 2012 7:11 pm Post subject: Cannot reproduce |
|
|
I can't reproduce any problem with the code that you posted. It works as expected both with the previous Encoder 6.5.16 and our latest series, and running on PHP 5.2.0, 5.2.14 that you're using, and PHP 5.3. You might check that you're using the highest update to 6.5, and you can update for free in the members' area if not.
So check carefully what you're doing, make sure that you really are using a recent Loader, and if you still have a problem then please create a support ticket at http://support.ioncube.com with sample code, and we'll see again if we can reproduce. _________________ Community Admin |
|
Back to top |
|
 |
|
|