Author |
Message |
Geoff4096
Joined: 07 Jun 2018 Posts: 4
|
Posted: Thu Jun 07, 2018 8:59 pm Post subject: session_set_save_handler: Argument 1 is not a valid callback |
|
|
Hi,
I'm using ionCube 10 to encode PHP 7.2.6 source file.
Script is a custom sessionhandler and contains the snippet
Code: | class Session {
.
.
.
.
/* Class constructor */
public function __construct( $dbDatabase, $dbTable, $dbServer = null, $dbHost = null, $dbUsername = null, $dbPassword = null, $autoStart = false ){
.
.
.
session_set_save_handler( array('Session', '_SessionOpen'),
array('Session', '_SessionClose'),
array('Session', '_SessionRead'),
array('Session', '_SessionWrite'),
array('Session', '_SessionDestroy'),
array('Session', '_SessionGc')); |
This works fine (no warning) in PHP interpreter but running with ionCube encode ("-72" or "-71") generates a runtime error
Code: | [07-Jun-2018 20:14:02 Europe/London] PHP Warning: [obfuscated](): Argument 1 is not a valid callback in ****/sessions.class.php on line 0 |
It's definitely this line it's complaining about since I can suppress the Warning with @
This piece of code used to work in encoder 7 (PHP 5.3) but no longer works in encoder 10. Has something changed / am I missing something?
I have tried various flavours of params to session_set_save_handler() but all are rejected with the above message (but work fine in 'raw' php).
Please advise.
Thanks.
Code: |
PHP Version 7.2.6
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.1, Copyright (c) 2002-2018, by ionCube Ltd. |
|
|
Back to top |
|
 |
alastair
Joined: 23 Feb 2010 Posts: 308
|
Posted: Fri Jun 08, 2018 8:36 am Post subject: |
|
|
Hi,
It is usually best to ask such questions in our Support Help Desk at https://support.ioncube.com
However, what is likely to have happened is that you have used "--obfuscate all" when encoding. Now, in version 10, "all" includes classes and methods rather than just functions. Thus a callback containing strings such as 'Session' and '_SessionOpen' will cause a problem as the "Session" class will be obfuscated as will be the method "_SessionOpen". So that renders the callback invalid.
There are two ways around this. To go back to version 7 behaviour, you should instead use "--obfuscate functions,locals,linenos". Alternatively, you can use an obfuscation exclusion file to list classes and method names that should not be obfuscated. In this case that will include the "Session" class and any methods used as callbacks in the way you have quoted. You will also need to exclude any built-in PHP classes and methods you have used. _________________ Alastair
ionCube |
|
Back to top |
|
 |
Geoff4096
Joined: 07 Jun 2018 Posts: 4
|
Posted: Fri Jun 08, 2018 8:35 pm Post subject: |
|
|
Excellent! Thanks for your quick response. You guessed correctly. Obvious when I think about it!
I should've paid more attention to the changelog I'd better read the (new) manual to get acquainted with the changes for v10.
I appreciate your comprehensive reply. I've now excluded the relevant classes/methods, as you suggested, and all works fine.
Thanks again. |
|
Back to top |
|
 |
|
|