NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Not really DBG


Joined: 15 May 2007
Posts: 11
Reply with quote
but you are all php debuggers, maybe you can help (I'm seeing this problem in my dbg session)
Using moodle, standard module require_once's a file config.php, which sets $CFG->somevars including $CFG->wwwroot, and then requires $CFG->wwwroot/lib/setup.php. In there, setup.php has a line
global $CFG.

Now, in normal use, this is ok, and $CFG keeps its values clean.

I'm adding a new module, so I include the same config.php as moodle does (cos I want some moodle setup info), and stepping thru, config.php does same stuff, setting up $CFG->vars. Lovely.
Then it require_once's $CFG->wwwroot/lib/setup.php, and the global $CFG line wipes out the contents of $CFG.
I can understand why it would, as the scoping of global says do this, but I cannot see why the original code would not.

Any ideas?

_________________
DS
View user's profileFind all posts by regionalserversSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
Did you put global $CFG in a very beginning of a function before using $CFG?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Not really DBG
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
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic