ionCube Logo
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder

Imported Encoded Files with Reflection Methods HALT Apache!

Author Message

Joined: 08 May 2012
Posts: 1
Location: USA

PostPosted: Wed May 09, 2012 11:14 am    Post subject: Imported Encoded Files with Reflection Methods HALT Apache! Reply with quote

Encoder Environment:
Files were encoded on a Windows 7 Pro 32 bit OS running the latest version of Encoder 7.0.9.

Server Environment: (WAMP 2.2)
OS: Windows 7 Pro 32 Bit
Apache: 2.2.21
PHP: 5.3.8

The following code example will halt Apache and reset your connection. The actual Apache error is "Parent: child process exited with status 255 -- Restarting.". There were no php_error.log errors to be found and error_reporting is set to E_ALL. All other php.ini settings are vanilla, max_execution_time 60 seconds and memory_limit = 256M.

I have not tested on Linux Server environment as yet. I will report soon with results of running same tests on Centos 5.x 32bit and 64bit servers running latest versions of PHP 5.3.x as soon as I can update PHP on those servers.

Here is the code: Please note that the example here has been reduced to the bare minimum to replicate the issue.

1.) Create a file named example.php which contains the following code:


class Example
public function __construct(){}

public function test($method)
$MyObject = new ReflectionObject($this);
$MyMethod = $MyObject->getMethod($method);
$MyParameter = $MyMethod->getParameters();

$third_arg_name = $MyParameter[2]->name; // this works
$third_arg_optional = $MyParameter[2]->isOptional(); // this works

$third_arg_available = $MyParameter[2]->isDefaultValueAvailable(); // this fails but only if encoded
$third_arg_value = $MyParameter[2]->getDefaultValue(); // this fails but only if encoded


2.) Create another file test.php which contains the following code:



class A extends Example
public function __construct()
print 'OK';

public function _someMethod($identifier,$value,$Parameter=true)
// code here not required for purposes of this test


$MyA = new A();


* Remember to place the encode example.php in a folder /encoded relative to the location of test.php file.

Tested the following cases:

CASE 1: Tested using example.php ENCODED. In test.php (NOT ENCODED) require_once of example.php file. FAILED

Case 2: Tested using same example.php NOT ENCODED. In test.php (NOT ENCODED) require_once of example.php file. PASSED

Case 3: Tested using the code that was contained in example.php copied code to start of test.php file and removed the require_once. Encoded the test.php file and tested the encoded version of test.php file containing ALL THE SAME CODE. PASSED

CASE 4: Tested using example.php (ENCODED) commented the lines for $third_arg_available and $third_arg_value ran test.php (NOT ENCODED) with require_once of example.php. PASSED

CASE 5: Same as CASE 1 tested but instead used require, include and include_once for importing example.php file. ALL FAILED

CASE 6: SAME AS CASE 1 except we modify the test.php by altering _someMethod 3rd argument as follows:
- Remove the default value of null: PHP correctly throws a ReflectionException as expected. So it recognizes the ReflectionParameter methods that are causing ioncube issues.
- Change the default value to true and remove the type hinting of array before the 3rd argument identifier. FAILS AGAIN.

Conclusion: combination of use of any import function(require,require_once,include,include_once) on files containing base classes extended by other classes and in which the base class contains certain Reflection methods may halt your server if and ONLY if encoded using ioncube.

I am assuming something internal to ioncube and how it handles imported encoded files may be at the root of this issue. Apparently there have been other import related issues unrelated to this case where require and/or require_once were at the root. This concerns me. As a side note I spent several hours trying to trace the issue and test as many different cases as possible but further testing would be useful especially using other versions of PHP and other Server environments so the issue can be isolated as much as possible.

If anyone has time to test in other environments I would be grateful.

Nick, let us know what you find and when this will be resolved. We use various Reflection classes and implement many abstract classes that contain Reflection related methods all of which are imported and extended by other classes. This unique case I reported may shed light on a deeper issue. Let us know either way, please.

Many Thanks,
Back to top
View user's profile Send private message

Joined: 11 Dec 2018
Posts: 3

PostPosted: Wed Sep 04, 2019 3:06 pm    Post subject: Reply with quote

Sorry for necro-posting but the issue described in this thread is happening to me with the latest version of ionCube.

For unknown reasons the same exact file fails to require_once another file when encoded with ionCube. It works without any problem decoded but the encoding "breaks" it in some way. It makes no sense to me. How can ionCube trigger PHP a fatal error (Failed opening required ecc.) for such a simple statement?

require_once 'vendor/autoload.php';
Back to top
View user's profile Send private message

Joined: 23 Feb 2010
Posts: 407

PostPosted: Wed Sep 04, 2019 4:36 pm    Post subject: Reply with quote


Please create a ticket about this in our Support Help Desk at

Having said that, if your issue is indeed similar to that created by moderncode in 2012, you should bear the following in mind:

1. Due to the way that PHP works, applying isDefaultValueAvailable() or getDefaultValue(), to an encoded function or method must itself be done from an encoded file. Why? Well, PHP finds default values by looping through the byte code to find specific instructions. With an encoded function, however, that will fail if it is done by PHP because the byte code is mangled to prevent decompilation. If, though, the reflection function is applied from an encoded file then the ionCube Loader will be able to intercept the reflection function and then use its own versions of getDefaultValue() and isDefaultValueAvailable() .

2. The encoded file to which reflection is being applied *must* be encoded with either the --allow-reflection-all option or a specific --allow-reflection option that will allow reflection to be applied to that specific function. The reason for this is the dynamic decoding feature that was introduced in version 9 of the Encoder, whereby functions are only decoded when they are first called. The --allow-reflection and --allow-reflection-all options basically say it is okay to apply reflection to a function (or functions) even though the function has not actually been called yet and therefore has not been decoded.

The GUI has equivalent settings to --allow-reflection and --allow-reflection-all in the "PHP functions that reflection methods can query" section in the Keys tab of the project settings (see

We do get asked about this quite regularly with regard to certain frameworks such as Yii which use the reflection functions I have described.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder All times are GMT + 1 Hour
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum