vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Strange problem in a plug-in (https://vborg.vbsupport.ru/showthread.php?t=103508)

sv1cec 12-22-2005 08:41 AM

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

Guest190829 12-22-2005 06:08 PM

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"); 


merk 12-22-2005 08:20 PM

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)

sv1cec 12-23-2005 04:59 AM

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

merk 12-23-2005 05:56 AM

If thats how the code is it wont work :)

You will have to use $this-registry to gain access to the db object.

sv1cec 12-23-2005 06:36 AM

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

Marco van Herwaarden 12-23-2005 06:40 AM

Inside classes use: &this->xxxxx
Outside use: $vbulletin->xxxxx

merk 12-23-2005 07:20 AM

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 :)

sv1cec 12-23-2005 10:32 AM

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

Thanks folks, appreciated!


All times are GMT. The time now is 01:12 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00941 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete