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.