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

session_set_save_handler: Argument 1 is not a valid callback

Author Message
Geoff4096



Joined: 07 Jun 2018
Posts: 4

PostPosted: Thu Jun 07, 2018 8:59 pm    Post subject: session_set_save_handler: Argument 1 is not a valid callback Reply with quote

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
View user's profile Send private message
alastair



Joined: 23 Feb 2010
Posts: 308

PostPosted: Fri Jun 08, 2018 8:36 am    Post subject: Reply with quote

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
View user's profile Send private message
Geoff4096



Joined: 07 Jun 2018
Posts: 4

PostPosted: Fri Jun 08, 2018 8:35 pm    Post subject: Reply with quote

Excellent! Thanks for your quick response. You guessed correctly. Obvious when I think about it!

I should've paid more attention to the changelog Wink 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
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