Web Server:
PHP version 5.2.13
IIS 7
Windows Server 2008 R2 Enterprise
MODx:
Revolution 2.0.0pl
Installed packages: codemirror, softmanagertheme, and wayfinder (all latest versions for Revolution)
Snippet not working - custom, see below
Environment:
Snippet "common" contains a line to include "common.php"
Default template contains "[[!common?]]"
"common.php" includes multiple other scripts and declares their class constructors like so:
require($modx->config['base_path'] . "/assets/include/session.php");
$session = new Session;
Problem:
When I pull a class from "common.php" out of the global scope, and into a function, it returns NULL.
The lines in question look like this:
function session_start(){
global $session;
var_dump($session);
}
So far:
I’ve been trying to understand the logic that may be behind this, as these scripts worked fine outside of MODx.
I have also tried using different variable names, incase MODx had $session reserved or other reasons. Perhaps the class constructor variables lose scope? Maybe they are nulled by MODx?
Time to re-re-re-read all the documentation on Revolution and see if I can’t spot why this is happening.
Thank you for looking at my post and hopefully I will be able to resolve this soon!
Update:
I’m able to solve this (temporarily) by declaring my constructor variables as superglobals, using $GLOBALS.
It’s not a solution just yet, but until I can solve the problem this will do.