General developer forum

 
 
Picture of shanthi peter
local plugin - simple question- global variable location ?
 

I created a simple  local/plugin

It does what it is supposed to do

I wanted to define a configuration variable like for e.g

define('NUMBERPERPAGE',60);

Now when I defined it in /local/pluginname/lib.php this variable was available only in /local/pluginname/install.php  but it was not available in  /local/pluginname/uninstall.php

I experimented around and found out that only if the global variable is defined in the file

/local/pluginname/version.php it is available both in

/local/pluginname/install.php and /local/pluginname/uninstall.php

Is this correct ? Should all global variables for a particular plugin be defined only in version.php ?

Shanthi

 

 

 

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: local plugin - simple question- global variable location ?
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

You should define it in lib.php, not version.php.

If need be, add a require_once in uninstall.php.

 
Average of ratings: -
Picture of shanthi peter
Re: local plugin - simple question- global variable location ?
 

I thought so. I will use lib.php to define the variables from now.

Just out of curiosity uninstall.php does not  contain variables from lib.php but install.php automatically does contain those variables even without the require_once.

Any particular reason(s) ?

Thanks

Shanthi

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: local plugin - simple question- global variable location ?
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Something else will already have required your lib.php in install.php.

(If you are really curious to find out where, add this debugging line to lib.php

format_backtrace(debug_backtrace());

That should show you where it is required from.)

 
Average of ratings: -
Picture of shanthi peter
Re: local plugin - simple question- global variable location ?
 

Thanks Tim

I got confused. The install.php was not including variables from lib.php at all in the first place

So now I had to use require_once in both install and uninstall. and all works well.

shanthi

 

 
Average of ratings: -