Can't Properly Delete Members

I tried deleting a test user I'd created on my live site, and the Ajax delete on the members view (admin panel) was not responding, but DID delete the member.  OK, no problem, though a touch annoying.

 

Then I created another test user, and tried to "Unregister".  I got a database error about "modzzz_answers_fans", there is no such table, and even a GREP for fans returns nothing but a reference to the word in the lang file for the mod.

 

This behavior is new in 7.0.7, I'm curious if anyone has this happen to them (with either other mods, base dolphin, or the modzzz answers mod).

 

I know this is not the best place to post for mod help, but I'm not certain it is the mod, when it could as easily be the core code that handles user deletion, looking for mod entries that don't/never existed in the first place.

Quote · 3 Aug 2011

Nobody?

Quote · 5 Aug 2011

Problem:

Database errors when trying to unregister as a member (create a test member, then try to unregister), I've found a solution.  This also solves trying to delete a member from admin, and...nothing happens, yet the member IS deleted when refreshing.  (Now it will update immediately in the list like it used to).

 

Scope:

Affects Dolphin 7.0.7 where modules are installed that do not account for _fans tables. (usually modules that are not designed to be compatible with 7.0.7 yet, but otherwise work just fine)

 

Solution:

Edit /inc/classes/BxDolTwigModuleDb.php

Find the function "removeFans" & "removeFanFromAllEntries"

Replace them with the following:

    function removeFans ($iEntryId, $aProfileIds) {
        if (!$aProfileIds)
            return false;
        $checkquery = "SELECT * `" . $this->_sPrefix . $this->_sTableFans . "`";
        $iDeletedCheck = @mysql_query($checkquery, $this->link);
        if ($iDeletedCheck)
        {
            $s = implode (' OR `id_profile` = ', $aProfileIds);
            $iRet = $this->query ("DELETE FROM `" . $this->_sPrefix . $this->_sTableFans . "` WHERE `id_entry` = '$iEntryId' AND `confirmed` = 1 AND (`id_profile` = $s)");
            if ($iRet)
                $this->query ("UPDATE `" . $this->_sPrefix . "main` SET `" . $this->_sFieldFansCount . "` = `" . $this->_sFieldFansCount . "` - $iRet WHERE `id` = '$iEntryId'");
            if ($iRet && $this->_sTableAdmins)
                $this->query ("DELETE FROM `" . $this->_sPrefix . $this->_sTableAdmins . "` WHERE `id_entry` = '$iEntryId' AND `id_profile` = $s");
        }
           return $iRet;
    }

    function removeFanFromAllEntries ($iProfileId) {
        $iProfileId = (int)$iProfileId;
        if (!$iProfileId || !$this->_sTableFans)
            return false;
        $checkquery = "SELECT * `" . $this->_sPrefix . $this->_sTableFans . "`";
        $iDeletedCheck = @mysql_query($checkquery, $this->link);
        if ($iDeletedCheck)
        {
                // delete unconfirmed fans
                $iDeleted = $this->query ("DELETE FROM `" . $this->_sPrefix . $this->_sTableFans . "` WHERE `confirmed` = 0 AND `id_profile` = " . $iProfileId);
                // delete confirmed fans
                $aEntries = $this->getColumn("SELECT DISTINCT `id_entry` FROM `" . $this->_sPrefix . $this->_sTableFans . "` WHERE `id_profile` = " . $iProfileId);
                foreach ($aEntries as $iEntryId) {
                    $iDeleted += $this->leaveEntry ($iEntryId, $iProfileId) ? 1 : 0;
                }       
        }
        return $iDeleted;
    }

 

In Depth:

Dolphin will attempt to clean up all user data when deleting a user.  One of the new functions of this is attempting to delete all data pertaining to this user (The one being deleted) from module databases from a new table called "bx_modulename_fans", But Dolphin does not yet first check to see if this table exists.  This solution wraps the action of deleting from the table, with a check to see if the table exists.

How it does this, is by trying to select everything in the table, if no result is returned whatsoever than either the table doesn't exist, or is empty and can be ignored anyways.  This check is done with basic MySQL commands, bypassing the Boonex DB Error checker, meaning no errors are presented to the user when attempting to select the table, and it is not found.

 

License:

I'm releasing this here free to all as a solution, It comes with no warranty.

As with any minimally tested solution, you run the risk of causing damage to your site.  While I cannot foresee this happening, I can't predict every permutation of site configuration, modules, and code modifications. I assume no responsibility for improper installation of this fix, or unintended effects from it's proper use.

Boonex is free - should they find this helpful - to include this fix in future versions.

Quote · 5 Aug 2011

Seems to have worked great, i can not see any faults so far will update if i find any here 

 

thanks pal

Quote · 14 Sep 2011

Good Solution.

Also, here is a simple way to update the individual module (that does not have fans) to prevent this error.

In the database connect class file (eg BxConfessionsDb.php)

Find :

        parent::BxDolTwigModuleDb($oConfig);

Just below, Add :


        $this->_sTableFans = '';

Paypal email is jeromemingo@gmail.com - http://www.boonex.com/market/posts/modzzz
Quote · 14 Sep 2011

Hello Modzzz, I have done it fakenets way.I have quite a few of your mods would it affect any of them?

Quote · 15 Sep 2011

There are no issues, both solution works. The solution I gave is suitable if you want to make a particular mod (which doesn't have fans) compatible with having to touch the Dolphin source code.

Hello Modzzz, I have done it fakenets way.I have quite a few of your mods would it affect any of them?

 

Paypal email is jeromemingo@gmail.com - http://www.boonex.com/market/posts/modzzz
Quote · 15 Sep 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.