Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2005, 08:41 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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");
I am not familiar with the new 3.5 conventions, but I can't find anything wrong with that statement, so any help would be greatly appreciated.

Rgds
Reply With Quote
  #2  
Old 12-22-2005, 06:08 PM
Guest190829
Guest
 
Posts: n/a
Default

Hm...try:

PHP Code:
$get_notes=$vbulletin->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"); 
Reply With Quote
  #3  
Old 12-22-2005, 08:20 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #4  
Old 12-23-2005, 04:59 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 12-23-2005, 05:56 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If thats how the code is it wont work

You will have to use $this-registry to gain access to the db object.
Reply With Quote
  #6  
Old 12-23-2005, 06:36 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #7  
Old 12-23-2005, 06:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Inside classes use: &this->xxxxx
Outside use: $vbulletin->xxxxx
Reply With Quote
  #8  
Old 12-23-2005, 07:20 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 12-23-2005, 10:32 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LoL, yes, that much, I 've figured already!

Thanks folks, appreciated!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04372 seconds
  • Memory Usage 2,232KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (8)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete