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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-02-2015, 05:40 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default "Registry object is not an object in" with "fetch_session_complete"

Now, as you are all aware.. I'm still learning a few things here and there. I recently got the idea to include some code into the fetch_session_complete hook for the users session. However, whenever I attempt to use any of my pre-existing code such as:

Code:
$userdata->set('usergroupid', xx);
I've been getting the error message "Registry object is not an object in" -> "class_dm.php"

I've already included quite a few files, including the global.php file but clearly I'm doing something wrong here. Any pinpointers are welcome. I do really hope I can even alter the usergroup within the fetch_session_complete hook.

Maybe I forgot to add more includes?

Code:
require_once(DIR . '/includes/functions.php');
require_once(DIR . '/includes/class_core.php');
require_once('global.php');
Reply With Quote
  #2  
Old 06-02-2015, 11:00 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you have a better example of what exactly you're trying to do in the fetch_session_complete hook? The $userdata object is obviously non existent at that hook location, unless you included it somewhere yourself.
Reply With Quote
  #3  
Old 06-02-2015, 11:47 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you creating the $userdata in your plugin? If so, at that hook you should use $this->registry instead of $vbulletin, or else put a "global $vbulletin;" (without the quotes of course) before you use $vbulletin.
Reply With Quote
  #4  
Old 06-02-2015, 04:53 PM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry about that, forgot to include the plugin code:

Code:
global $vbulletin;

$dataman =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$dataman->set_existing($vbulletin->userinfo); 

if (stuff here)
{
$dataman->set('usergroupid', 8);
$dataman->save();
}
For the sake of trying, I've replaced the main code of (stuff here) with:
Code:
IF ($vbulletin->userinfo['usergroupid'] == 9)
The bold is what I recently added, but getting this as a result:

Code:
Fatal error: Existing data passed is not an array
Called set_existing in /vbulletin/includes/class_core.php(4016) : eval()'d code on line 5
Called eval in /vbulletin/includes/class_core.php on line 4016
Called fetch_session in /vbulletin/includes/class_core.php on line 3757
Called vB_Session in /vbulletin/includes/init.php on line 647
Called require_once in /vbulletin/includes/class_bootstrap.php on line 101
Called init in /vbulletin/includes/class_bootstrap.php on line 72
Called bootstrap in /vbulletin/global.php on line 26
Called require_once in /vbulletin/forum.php on line 67
Called require in /vbulletin/index.php on line 43
in /vbulletin/includes/class_dm.php on line 265
Also tried $this->registry to replace vbulletin->userinfo, same message. Does this mean I need to include those php files? Or global already includes it, but the first "fatal error" is something I need to pay attention to.
Reply With Quote
  #5  
Old 06-02-2015, 07:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, right. That hook is called in the middle of setting up $vbulletin, and the userdata hasn't been set yet. Is there any reason you need to use that hook? Maybe use something like global_setup_complete instead, if you can.
Reply With Quote
  #6  
Old 06-02-2015, 07:45 PM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The reason why I'm aiming for the session hook is because the session is only called when the session timer has elapsed, thus the php plugin would only be called for once every xx min/hours depending on the session settings I would use. Thus less queries in the end, rather than being called every single time the user browses the forums with, eg global_setup_complete.

If you have any other good hook or php code that only runs on the user eg, once per specified hours.. that'll be awesome. Though only when the user is browsing the forums.
Reply With Quote
  #7  
Old 06-02-2015, 11:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you sure that hook's only called when a session has expired? It seems like a session object would have to be created every page load. But you could be right, I haven't studied it closely. Anyway, if it's true then one thing you could do is have a plugin using hook fetch_session_complete that just sets a global variable to true, then in global_setup_complete check that variable and only do the rest if it's true. I think that achieves the same thing except that $vbulletin will be completely set up when your code runs.
Reply With Quote
Благодарность от:
MarkFL
  #8  
Old 06-03-2015, 05:27 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Am I sure? No, but I have noticed that the fetch_session_complete hook is not called every time the use browses the forums or refreshes the page. Only after a specific time, so I figured it would have to do with the session time.

Got an example for both of them btw? Still a newbie at this .

Like I said.. if you have any better replacements for this, I'm happy to hear it.

if I would to include it into a hook like global_setup_complete, it would only check plugin every time the user refreshes the browser or browses through the forums. I prefer to avoid such constant checks, but rather do it in a timely matter. Unless of course a new hook can be created that only executes on the user once per hour, and only triggers once for the user when he browses the forums, and again after the hour expired and visits the forums again but doesn't check his profile after that hour expired, it has to be when he's active on the forums instead.
Reply With Quote
  #9  
Old 06-03-2015, 08:46 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, so on hook fetch_session_complete you'd do this:
PHP Code:
global $do_something;
$do_something true
Then in global_setup_complete:
PHP Code:
global $do_something
if (
$do_something)
{
  
// your other code here


Obviously you can choose whatever variable name you want in place of $do_something. Choose something that's unlikely to conflict with an existing global.
Reply With Quote
  #10  
Old 06-04-2015, 06:55 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So:

fetch_session_complete
Code:
global $lowlevelundocheck;
$lowlevelundocheck = true;
global_setup_complete
Code:
global $lowlevelundocheck; 

$userdata_rank =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata_rank->set_existing($vbulletin->userinfo); 

if ($lowlevelundocheck)
{
$userdata_rank->set('usergroupid', 2);
$userdata_rank->save();
}
Unsure what I'm doing wrong, but nothing happens. It should move my test profile to usergroup ID (currently in another group)
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 10:41 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.05454 seconds
  • Memory Usage 2,262KB
  • 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
  • (7)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete