Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 05-22-2015, 09:22 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Oh, wait. were you saying that you depend on $vbulletin->userinfo['usergroupid'] == 13 being false in the second one to prevent it from running if the first one already did? Because using the datamanager to change the usergroup will not change $vbulletin->userinfo['usergroupid'] (I don't think).
Indeed. If the usergroupID is no longer 13 for the user on the second plugin, it shouldn't be executing at all. If that's the case, do you have a better recommendation for a code to move users to another group?
Reply With Quote
  #12  
Old 05-22-2015, 09:32 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually I'm sorry, I was wrong. It appears that the datamanager does in fact update the userinfo if you're changing the current user. I never knew that.
Reply With Quote
  #13  
Old 05-22-2015, 09:34 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You learn something everyday! .

Which still makes me curious why the execution order isn't working properly. ^^
Reply With Quote
  #14  
Old 05-27-2015, 09:45 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm pretty sure that the execution order is screwed up.

I have this as execution order 2,3 and even tried 4:
Code:
$userdata_rank->set('usergroupid', 42);
$userdata_rank->save();
at a specific hook when forum members link their steam account. Simple enough, move user to UsergroupID 42.

This works great, awesome!

Now I've added another plugin to check if the user has been flagged on SteamREP.com as a scammer.

I've disabled the usergroupID 42 move plugin to see after I steam linked my profile on the forums I would be banned.. and, it works!

Now, if I enable both of them (move usergroupdID execution order 2, 3 or 4) with the second steamrep ban plugin execution order 1. I get moved to usergroupID 42, rather than the specific steamrep banned usergroup of which is 26.

So, which made me wonder.. what if execution order 2, 3 or 4 beats 1? So I used the following code at the plugin with execution 2, 3 or 4 (tried all 3):

Code:
if (!in_array($vbulletin->userinfo['usergroupid'], array(26)) )
{
$userdata_rank->set('usergroupid', 42);
$userdata_rank->save();
}
26 is ignored, and tada..!! everything suddenly worked.

Now, once again.. why isn't execution order doing its job? Both of these plugins are using the exact same hook. Is it broken? Has anyone tested it? Does execution order depends on the amount of the code? If one is smaller than the other, second one is being executed faster? What's the deal?
Reply With Quote
  #15  
Old 05-27-2015, 09:57 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Honestly, I find it hard to follow what exactly you are doing, but if I read you correctly, your logic and your expectations seem to be at fault.

What you're describing:

- plugin at exec order 1 that puts the user into ug 26.
- second plugin at exec order 2, 3 or 4 that puts the user into ug 42.

Both plugins are executed one after another. Result: The user ends up in ug 42. What else do you expect?

This is confirmed by your second bit of code. Now you tell the second plugin to only move the user into ug 42 if he has not prior been moved to ug 26. Then he stays in 26. If you don't do that check, every user is moved to 42, whatever his prior ug.

Again: That is correct and perfectly logical. I just don't see what else you could expect as a result based on the information you're giving.
Reply With Quote
  #16  
Old 05-27-2015, 10:12 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Indeed, I just have checked and noticed a flaw in my execution order.. so, I switched them.

The first plugin, with execution order 1:
Code:
$userdata_rank->set('usergroupid', 42);
$userdata_rank->save();
Should move any user that steam linked to usergroupID 42.

The second plugin now with execution order 2 but with a much larger code but ends up with this:

Code:
if (!in_array($vbulletin->userinfo['usergroupid'], array(6,7,5)) )

RESTOFTHECODE HERE

        $dataman->set('usergroupid', 26);
        $dataman->save();
^ Code above is not the full code, you get the idea what the code does. but basically means it ignores usergroupID 6,7 and 5 and moves to the user to usergroupID 26.

Oddly enough, when both plugins are active.. the end results are that I'm being moved into usergroupID 42. Which makes me wonder, why. The second plugin is designed to move the user to usergroupID 26 despite whatever usergroup he/she is in (but ignores the specified 3 usergroups).

Which makes me assume, that plugin 2 runs first, and then executes the first plugin with execution order 1. if I disable the first plugin (usergroupID 42), I'm being moved perfectly to usergroupID 26 that is executed by the second plugin.

So.. I'm expecting this:

First plugin -> Steam Link -> Move user to Usergroup 42
Second plugin -> Steam link -> Check steamrep.com -> User is flagged -> Move to usergroupID 26

Seeing the second plugin only ignores usergroupID 6,7 and 5 (which the user isn't even getting into) it should move the user IF the execution order was done properly.

Yet, as I stated.. I end up being in usergroupID 42, rather than 26.

From the way I see things, the execution order isn't working as it should.. It could be me, or the code. but as far as I'm concerned, both plugins are working perfectly if they are running separately. (eg, one is on, other is off)
Reply With Quote
  #17  
Old 05-27-2015, 11:45 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is your code. Has to be.

It's easy to make sure, and always a good idea to do testing with the most basic approach possible:

Create two plugins at login_process, with execution order set to 1 and 2 respectively.
PHP Code:
echo "exec order 1 "
PHP Code:
echo "exec order 2 "
This prints the expected result when logging in, on top of the page during the redirection process:
HTML Code:
exec order 1 exec order 2
Whatever the issue is with your approach, it is not the execution order. It works as expected, and quite honestly, the execution order was introduced way back in the vB3.x days. I'm pretty sure a bug like that would have been found out at some point during the last, like, ten years.
Reply With Quote
  #18  
Old 05-27-2015, 01:50 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The limited bit of code you're actually supplying is making it difficult to diagnose what's going on, but based on the first, more complete, code provided in the third post I would expect the user to remain in the usergroup they are set to in the plugin at execution order 1.

Why do you have the code in two separate plugins instead of in just a single plugin given the code is supposed to run serially (i.e. one after another) anyways?
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:01 AM.


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.08426 seconds
  • Memory Usage 2,243KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (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
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete