The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Strange problem in a plug-in
I am trying to use a simple query in a plug-in, located in the postbit_display_start hook, and for some strange reason, it crashes with the following error:
Fatal error: Call to a member function on a non-object in /home/xxx/xxx/includes/class_postbit.php(251) : eval()'d code on line 80 The code in that line, looks like: Code:
$get_notes=$db->query_read("select w.*, u.username as warner from ".TABLE_PREFIX."warn_notes w LEFT JOIN ".TABLE_PREFIX."user u on (u.userid=w.warned_by) where warned_user='{$post[userid]}' order by warned_time desc"); Rgds |
#2
|
|||
|
|||
Hm...try:
PHP Code:
|
#3
|
|||
|
|||
postbit_display_start is inside a class. You will need to use $this->registry instead of $vbulletin. Also be aware your query location is going to cause a query for every post on a page, if someone was in 100pp mode, there would be 100 queries just for your addition. (on top of the showthread queries)
|
#4
|
|||
|
|||
Yes, I know, I think this is something I should address, but at the moment, that's how the code is. I have some idea on how to improve it.
Thanks |
#5
|
|||
|
|||
If thats how the code is it wont work
You will have to use $this-registry to gain access to the db object. |
#6
|
|||
|
|||
Question: will $this-registry work everywhere, or there are places that your SHOULD use $this-registry and other places that you SHOULD user $vbulletin?
Tnx |
#7
|
|||
|
|||
Inside classes use: &this->xxxxx
Outside use: $vbulletin->xxxxx |
#8
|
|||
|
|||
Most hooks inside classes will have "data" ie "userdata_start" in them, but some wont. As Marco said, youll need to mix and match, BUT you should be able easily tell them apart by the error.
If you get "Call to a member function on a non-object " you're using the wrong one |
#9
|
|||
|
|||
LoL, yes, that much, I 've figured already!
Thanks folks, appreciated! |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|