The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Recursive Member Requests via AJAX Causes Bugs

View previous topic View next topic Go down

Recursive Member Requests via AJAX Causes Bugs

Post by Ange Tuteur on Fri 01 Apr 2016, 22:06

Hi,

This is rather a very technical problem, so if any of you would be able to report this to the higher ups for clarification, I'd love you for that. loove

Description : When sending recursive requests to the profiles, after about 50 or so I begin to experience some wonky results. Which are :

1. When trying to view a user's profile it's never the correct user associated with the id. e.g. Viewing user 1 would show user 5
2. When trying to view a topic it always goes to topic 1.

Demonstration :
Example of what I'm doing :


Result after prolonged use :

It's like I'm playing some kinda random user game ! Shocked

Solution / Quirks : I can stop this buggy result from happening after clearing my cookies ( usually just the session id ) or logging out. HOWEVER, I can send plenty of AJAX requests to the user page while logged out and NEVER get this wonky result. I wouldn't have a problem with this, but I need to be logged in to edit the user profiles.

Code : I whipped up an example code similar to what I'm doing. Go to your forum while logged in, press F12, go to console and paste the following code :
Code:
window.member_crawler = {
  index : 0,
  quota : 100,
  data : '#field_id-6',

  get : function() {
    if (++member_crawler.index <= member_crawler.quota) {
      console.log('Getting user ' + member_crawler.index + '/' + member_crawler.quota + '...');

      $.get('/u' + member_crawler.index, function(d) {
        var name = $('#cp-main h1', d).text(),
            field = $(member_crawler.data, d).text();

        console.log((field ? name.replace(/All about /, '') + ' = ' + field : 'USER NOT FOUND.') + '\n\n');
        window.setTimeout(member_crawler.get, 1000);
      });

    } else {
      console.log('COMPLETE!');
    }
  }
};

member_crawler.get();
Make sure to change the quota property so it reads the total amount of members on your forum. Once you're finished hit enter and the code will begin crawling your members to get their posts amount. After awhile of crawling the results will begin repeating some users due to the bug mentioned above. NOTE : That you must have a large amount of members on your forum for this to occur.

The requests are delayed 1 second after they're completed. I tried raising this to 3 seconds, 5 seconds, and even 10 seconds, but I still end up with the same result. What I don't get is that I can continuously get members profiles while logged out without this happening. I'm assuming it has something to do with cookies or I could be wrong. Think

Why am I doing this ? : I'm doing this because I need to check the user information AND update a specific profile field to reflect the user's achievements.

If you need more information lemme know. Have a good weekend. bye

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Re: Recursive Member Requests via AJAX Causes Bugs

Post by Ange Tuteur on Sat 02 Apr 2016, 18:55

Well, I wrote a workaround solution for what I'm doing, so I'm not too worried about this anymore. However, I still think this should be reported when possible, because it appears to be some sort of bug. Think

There's no rush though, take your time. Doff

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum