Yarnell Posted December 28, 2023 Share Posted December 28, 2023 Hey all, I am using the following code in a php script to grab config data and db data, this works perfectly. require 'ini.inc.php'; define('ADMIN_CP', true); require 'includes/functions.inc.php'; $GLOBALS['cache'] = Cache::getInstance(); $GLOBALS['db'] = Database::getInstance($glob); $GLOBALS['config'] = Config::getInstance($glob); unset($glob); $GLOBALS['config']->merge('config', '', $config_default); I am having trouble getting user data... when I add: $GLOBALS['user'] = User::getInstance(); It results in the following error: [Wed Dec 27 20:19:02.242234 2023] [proxy_fcgi:error] [pid 13504] [client 192.168.0.5:25441] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function load() on null in /XXX/classes/user.class.php:1135\nStack trace:\n#0 /XXX/classes/user.class.php(143): User->_load()\n#1 /XXX/classes/user.class.php(167): User->__construct()\n#2 /XXX/player.php(19): User::getInstance()\n#3 {main}\n thrown in /XXX/classes/user.class.php on line 1135', referer: https://domain.com Is there a way to get data from the current user instance? Thanks -- Yarnell Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 28, 2023 Share Posted December 28, 2023 (edited) Please show us line 1135 in the file /classes/user.class.php. I cannot determine what version of CubeCart has user.class.php, line 1135, has a statement that makes a call to load(). The closest statement I can see is a call to $GLOBALS['hooks']->load('class.user.load'). So, generally speaking, CubeCart has a specific sequence of waking up that has very little leeway - where a call to instantiate class 'n+1' will require that class 'n' be instantiated first. That is to say, instantiating User might require that every class listed ahead of it be instantiated first -- in this case, at least the Hookloader class and Session class, which themselves might require earlier listed classes be instantiated, such as Language and Debug. Try including controller.index.inc.php -- which might require you to check the necessity for define('ADMIN_CP', true);. Edited December 28, 2023 by bsmither Quote Link to comment Share on other sites More sharing options...
Yarnell Posted December 28, 2023 Author Share Posted December 28, 2023 Awesome. I ended up using the following code: require dirname(__FILE__).DIRECTORY_SEPARATOR.'ini.inc.php'; define('CC_IN_ADMIN', false); include CC_ROOT_DIR.CC_DS.'controllers'.CC_DS.'controller.index.inc.php'; Many thanks Brian Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.