Hi everyone,
I am trying to develop a new extension (just for fun and just to get more knowledge about EE). However in my extension $LANG and $SESS objects are never loaded. When I var_dump, I see that they are NULL. Other objects are working fine.
I have an empty function in my extension that starts with the below lines
function empty_function(){
global $SESS, $IN, $DB, $LANG;
var_dump($SESS);
var_dump($LANG);
var_dump($IN);
var_dump($DB);
}
the output for sess and lang are null. Am i missing something? If you have any tip, I’ll be glad to hear them. Thanks.
Can Berkol
First problem is solved. I was using sessions_end hook which is used with a parameter. (documentation says $this, of course if you pass parameter with the name $this under PHP5 environment then you will get an error). Anyhow, I was for some reason ignoring that sessions_start required a param. When I modified the function to this
function empty_function($SESS){
global $IN, $DB, $LANG;
var_dump($SESS);
var_dump($LANG);
var_dump($IN);
var_dump($DB);
}
I was successfull able to access to content of $SESS.
Now, I have to figure out what’s wrong with $LANG. Maybe $LANG is not supported with extensions, huh? What do you say? 😊 hmmm….
It seems like each hook supports different globals (classes). As far as I understood sessions_start hook does not support $LANG.
May be I could’nt find that info in documentation but if it is not there I think this is an important piece of knowledge for developers and it should be included.
So basically, problem is solved. Lessons learned are:
1- Do not ignore hook parametes. 2- Not all the hooks support all the core classes.
If I’m wrong feel free to correct me.
Thanks, Can Berkol
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.