PDA

View Full Version : evaled on page generation


calorie
06-09-2005, 10:55 PM
First and foremost plug-ins are stored in the database, serlized, unserlized and evaled on page generation.
What exactly does the part in bold mean, and is there a risk of variable name collision?

Andreas
06-09-2005, 11:03 PM
If you take a look at table datastore for record pluginlist you will find smth. linke this:


a:1:{s:12:"global_start";s:32:"// some code for hook global.php"}


This is a serialized array.
Upon execution it will be unserialized:

$pluginlist['global_start'] = '// Some code for global.php';


Then this code will be executed:

eval($pluginlist['global_start']);


Variable collisions are always possible.
As this unserializing and evaluating is being done at execution time it generates overhead. So for larger code modifications you might want to use include files - then less code must be unserailized and evaled.
Include files can also be pre-compiled/cached -> eAccelerator/ZEND Performance Suite/etc.

calorie
06-09-2005, 11:06 PM
When are plugins first available, i.e., is a plugin first available in init.php or global.php or ???

Andreas
06-09-2005, 11:07 PM
I don't understand this question.

calorie
06-09-2005, 11:09 PM
As this unserializing and evaluating is being done at execution time it generates overhead. So for larger code modifications you might want to use include files - then less code must be unserailized and evaled.
Include files can also be pre-compiled/cached -> eAccelerator/ZEND Performance Suite/etc.
So, do you mean just use an include statement to not store so much stuff? By evaluating, do you mean just the plugin code is evaluated, or is it all included files?

I don't understand this question.
Say I make a plugin that sets variable $foo - I am wondering when $foo is first available: a) by plugin and b) by hack.

EDIT: Argh, the Automerged Doublepost got me! :D

Andreas
06-09-2005, 11:15 PM
Only the include statement. Of yourse the included file must aso be parsed/compiled, but as already said files can be cached.

Say I make a plugin that sets variable $foo - I am wondering when $foo is first available: a) by plugin and b) by hack.
I don't understand this question, sorry.
What to you want to know - variable scope?
If your plugin is being called from within a function, the any variables you set (if you don't define them as global) will only be visible within this function.
If your plugin is being called from a global scope, then variables will be global.

calorie
06-09-2005, 11:18 PM
Okay, thanks. Now when is $foo from a plugin first available, i.e., what is the first file that $foo will be able to be used in, if $foo is set via plugin?

Andreas
06-09-2005, 11:20 PM
Okay, thanks. Now when is $foo from a plugin first available, i.e., what is the first file that $foo will be able to be used in, if $foo is set via plugin?
$foo will be available after the plugin was called.

calorie
06-09-2005, 11:24 PM
$foo will be available after the plugin was called.

Right, but when is the plugin first called? I see some code in init.php, so are hooks/plugins available at the end of init.php but before global.php?

Andreas
06-09-2005, 11:27 PM
Right, but when is the plugin first called?
That depends on the hook you are using.
The first hook being called is fetch_userinfo from init.php (line 362):

$vbulletin->userinfo =& $vbulletin->session->fetch_userinfo();

calorie
06-09-2005, 11:33 PM
ignore

Andreas
06-09-2005, 11:37 PM
Man, I don't get you.

Variables set in a Plugin will be available after the Plugin was called - and this time depepends on the hook.

Example
Variables set in a Plugin for hook forumdisplay_start will be avialable in code executed after forumdisplay.php line 98.

calorie
06-09-2005, 11:42 PM
Man, I don't get you.

Variables set in a Plugin will be available after the Plugin was called - and this time depepends on the hook.

Example
Variables set in a Plugin for hook forumdisplay_start will be avialable in code executed after forumdisplay.php line 98.

LOL, thanks for your patience, let me try to ask another way... :devious:

What is the first vB file where set_session_visibility() is available by plugin?

Andreas
06-09-2005, 11:51 PM
Every File.

calorie
06-10-2005, 12:05 AM
Every File.

Including at the top of init.php?

Andreas
06-10-2005, 12:08 AM
No. OK, to be more precise:
Every php file that is not an include-/class-file.
Or in other words as already said:


The first hook being called is fetch_userinfo from init.php (line 362)

calorie
06-10-2005, 12:17 AM
ignore

Andreas
06-10-2005, 12:18 AM
I give up. Maybe somebody else is able to explain it to you :(

calorie
06-10-2005, 12:40 AM
got it. thanks for helping. :)