SVN [1518] - Alts do not update according to rules

Posts from previous Beta sessions

SVN [1518] - Alts do not update according to rules

Postby Feithar » Wed Dec 19, 2007 10:33 pm

I've been running SVN 1286 for a while, and recently moved to 1518. After I switched, I noticed that alts would only be updated correctly if I manually clicked the update button in the configuration screen, and whenever the profiler data was uploaded, alt data would always get wiped out.

It looks like what's happening is the rules are not actually being stored in the $data variable when they are read in during the MemberList guild_pre function call, even though it looks like it should. I was able to fix the problem by creating a global variable which I copied $data into at the end of guild_pre, then I copy the global variable back into $data at the start of every other function in the MemberList update_hook.php file (if you'd like, I can post a diff of my changes when I get home from work tonight).

I think this is the same problem that I described in this thread a while back. Essentially, when you iterate through each of the addons using foreach in PHP (at least in PHP 4.4.1, which is what I'm running), PHP makes a copy of each object in the array, so when you are reading in the rules and storing them, they're getting stored in the copy of the addon object rather than the original. I had suggested making an alteration in update.lib.php to work around this issue since I think the problem is in the use of foreach rather than anything in memberlist itself.

Hope this helps. It's my only complaint about an otherwise absolutely amazing tool, and if this issue can be fixed, you would absolutely make my year. Thanks!
User avatar
Feithar
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Sun Nov 26, 2006 7:58 am

SVN [1518] - Alts do not update according to rules

Postby Samadhi » Thu Dec 20, 2007 12:00 am

This is fixed in the latest version (1545).
Image
User avatar
Samadhi
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 114
Joined: Mon Jul 17, 2006 10:38 pm
Location: NJ, USA

SVN [1518] - Alts do not update according to rules

Postby zanix » Thu Dec 20, 2007 5:36 am

Feithar - Try this patch to update.lib.php

Code: Select all
Index: update.lib.php
===================================================================
--- update.lib.php   (revision 1549)
+++ update.lib.php   (working copy)
@@ -241,25 +241,25 @@
       {
          if( is_array($this->addons) && count($this->addons)>0 )
          {
-            foreach( $this->addons as $addon )
+            foreach( array_keys($this->addons) as $addon )
             {
-               if( count(array_intersect($gotfiles, $addon->files))>0 )
+               if( count(array_intersect($gotfiles, $this->addons[$addon]->files))>0 )
                {
-                  if( file_exists($addon->data['trigger_file']) )
+                  if( file_exists($this->addons[$addon]->data['trigger_file']) )
                   {
-                     $addon->reset_messages();
-                     if( method_exists($addon, 'update') )
+                     $this->addons[$addon]->reset_messages();
+                     if( method_exists($this->addons[$addon], 'update') )
                      {
-                        $result = $addon->update();
+                        $result = $this->addons[$addon]->update();
 
                         if( $result )
                         {
-                           $output .= $addon->messages;
+                           $output .= $this->addons[$addon]->messages;
                         }
                         else
                         {
-                           $output .= sprintf($roster->locale->act['error_addon'],$addon->data['fullname'],'update') . "<br />\n"
-                           . $roster->locale->act['addon_messages'] . "<br />\n" . $addon->messages;
+                           $output .= sprintf($roster->locale->act['error_addon'],$this->addons[$addon]->data['fullname'],'update') . "<br />\n"
+                           . $roster->locale->act['addon_messages'] . "<br />\n" . $this->addons[$addon]->messages;
                         }
                      }
                   }
@@ -284,37 +284,37 @@
       global $roster;
 
       $output = '';
-      foreach( $this->addons as $addon )
+      foreach( array_keys($this->addons) as $addon )
       {
-         if( file_exists($addon->data['trigger_file']) )
+         if( file_exists($this->addons[$addon]->data['trigger_file']) )
          {
-            $addon->reset_messages();
-            if( method_exists($addon, $mode) )
+            $this->addons[$addon]->reset_messages();
+            if( method_exists($this->addons[$addon], $mode) )
             {
-               $result = $addon->{$mode}($data , $memberid);
+               $result = $this->addons[$addon]->{$mode}($data , $memberid);
 
                if( $result )
                {
                   if( $mode == 'guild' )
                   {
-                     $output .= '<li>' . $addon->messages . "</li>\n";
+                     $output .= '<li>' . $this->addons[$addon]->messages . "</li>\n";
                   }
                   else
                   {
-                     $output .= $addon->messages . "<br/>\n";
+                     $output .= $this->addons[$addon]->messages . "<br/>\n";
                   }
                }
                else
                {
                   if( $mode == 'guild' )
                   {
-                     $output .= '<li>' . sprintf($roster->locale->act['error_addon'],$addon->data['fullname'],$mode) . "<br />\n"
-                     . $roster->locale->act['addon_messages'] . "<br />\n" . $addon->messages . "</li>\n";
+                     $output .= '<li>' . sprintf($roster->locale->act['error_addon'],$this->addons[$addon]->data['fullname'],$mode) . "<br />\n"
+                     . $roster->locale->act['addon_messages'] . "<br />\n" . $this->addons[$addon]->messages . "</li>\n";
                   }
                   else
                   {
-                     $output .= sprintf($roster->locale->act['error_addon'],$addon->data['fullname'],$mode) . "<br />\n"
-                     . $roster->locale->act['addon_messages'] . "<br />\n" . $addon->messages . "<br />\n";
+                     $output .= sprintf($roster->locale->act['error_addon'],$this->addons[$addon]->data['fullname'],$mode) . "<br />\n"
+                     . $roster->locale->act['addon_messages'] . "<br />\n" . $this->addons[$addon]->messages . "<br />\n";
                   }
                }
             }


If you cant use this patch file, then download the whole changed file below
Attachments
update.lib.zip
update.lib.php foreach copy fix
(17.53 KiB) Downloaded 221 times
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: SVN [1518] - Alts do not update according to rules

Postby Feithar » Thu Dec 20, 2007 8:14 am

Ended up downloading the file since my web server doesn't supply me with the patch command... :(

However, that seems to have fixed the issue. I removed all of my modifications, replaced the update.lib.php file with the one you posted above, and everything seems to be working fine. :)

Thanks a million. You all are the best!

P.S. Any plans to port SigGen to 2.0? :)
User avatar
Feithar
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Sun Nov 26, 2006 7:58 am

SVN [1518] - Alts do not update according to rules

Postby zanix » Thu Dec 20, 2007 8:17 am

Feithar wrote:Ended up downloading the file since my web server doesn't supply me with the patch command... :(

However, that seems to have fixed the issue. I removed all of my modifications, replaced the update.lib.php file with the one you posted above, and everything seems to be working fine. :)

Thanks a million. You all are the best!

Good deal, I will add this to the SVN

Feithar wrote:P.S. Any plans to port SigGen to 2.0? :)

It's already ported, check the SigGen forum
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

SVN [1518] - Alts do not update according to rules

Postby Feithar » Thu Dec 20, 2007 1:42 pm

It's already ported, check the SigGen forum


Awesome - thanks!
User avatar
Feithar
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Sun Nov 26, 2006 7:58 am

SVN [1518] - Alts do not update according to rules

Postby PleegWat » Thu Dec 20, 2007 4:11 pm

For future reference: It is possible to explicitly foreach by reference by replacing:

for( $array as $value )

with

for( $array as &$value )

This usually results in easier to read code than what is suggested above. I won't bother fixing it till the next time I need to work on it though.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm


Return to Archived

Who is online

Users browsing this forum: No registered users and 1 guest

cron