• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • Undefined Index: user_group_id when merging users

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Undefined Index: user_group_id when merging users

    • Issue Tools
      • View Changes
    1. issueid=5121 June 21, 2017 4:42 PM
      Forsaken Forsaken is offline
      Junior Member
      Undefined Index: user_group_id when merging users

      Code:
      Undefined index: user_group_id
      
      XenForo_Application::handlePhpError() in XenForo/Model/User.php at line 1728
      XenForo_Model_User->isMemberOfUserGroup() in /home/community/vault/core/model/user/xf.php at line 235
      vw_User_Model_XF->member_of() in /home/community/vault/core/model/plugins/data/vw.php at line 362
      vw_Plugins_Data_Model->do_user_merge_target_required() in /home/community/vault/core/model/plugins/data/vw.php at line 89
      vw_Plugins_Data_Model->do_user_merge() in vw/XenForo/Model/User.php at line 134
      vw_XenForo_Model_User->changeContentUser() in XenForo/Model/User.php at line 3080
      XenForo_Model_User->mergeUsers() in EWRporta2/Model/User.php at line 7
      EWRporta2_Model_User->mergeUsers() in EWRdiscord/Model/User.php at line 61
      EWRdiscord_Model_User->mergeUsers() in XenGallery/Model/User.php at line 7
      XenGallery_Model_User->mergeUsers() in XenForo/ControllerAdmin/User.php at line 646
      XenForo_ControllerAdmin_User->actionMerge() in XenForo/FrontController.php at line 351
      XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
      XenForo_FrontController->run() in /home/community/admin.php at line 13
      I get this error when trying to merge users.
    Issue Details
    Issue Number 5121
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category Admin Panel
    Status Fixed
    Priority 3 - Loss of Functionality
    Affected Version 4.0.18
    Fixed Version 4.0.19
    Milestone (none)
    Software DependencyXenForo 1.x
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. June 22, 2017 9:25 AM
      pegasus pegasus is offline
      VaultWiki Team
      In library/vw/XenForo/DataWriter/User.php, find:
      Code:
      protected function _postDelete()
      Before it, add:
      Code:
      	protected function _preDelete()
      	{
      		// make sure the deleted user is stored for postDelete
      		$user = vw_Hard_Core::controller('Fetch')->get('User', $this->get('user_id'));
      
      		parent::_preDelete();
      	}
      Find:
      Code:
      		parent::_postDelete();
      
      		$user = array('userid' => $this->get('user_id'));
      Replace with:
      Code:
      		$user = vw_Hard_Core::controller('Fetch')->get('User', $this->get('user_id'));
      
      		if (!$user)
      		{
      			$user = array('userid' => $this->get('user_id'));
      		}
      
      		parent::_postDelete();
      In library/vw/XenForo/Model/User.php, find:
      Code:
      		if ($newUserId === null)
      		{
      			vw_Hard_Core::model('Plugins/Data')->do_user_name($newUserName, array(
      				'userid' => $existingUserId,
      				'username' => $oldUserName
      			));
      		}
      		else
      		{
      			vw_Hard_Core::model('Plugins/Data')->do_user_merge(
      				array(
      					'userid' => $existingUserId,
      					'username' => $oldUserName
      				),
      				array(
      					'userid' => $newUserId,
      					'username' => $newUserName
      				)
      			);
      		}
      Replace with:
      Code:
      		if ($newUserId === null)
      		{
      			$olduser = vw_Hard_Core::controller('Fetch')->get('User', $existingUserId);
      
      			if ($olduser)
      			{
      				// only do this if the user wasn't deleted before we got here
      				vw_Hard_Core::model('Plugins/Data')->do_user_name($newUserName, array(
      					'username' => $oldUserName
      				) + $olduser);
      			}
      		}
      		else
      		{
      			$userids = array($existingUserId);
      
      			if ($newUserId)
      			{
      				$userids[] = $newUserId;
      			}
      
      			$users = vw_Hard_Core::controller('Fetch')->get('User', $userids);
      
      			if (!$newUserId)
      			{
      				$users[0] = array(
      					'user_id' => 0,
      					'userid' => 0,
      					'user_group_id' => VW_GUEST_GROUP,
      					'usergroupid' => VW_GUEST_GROUP
      				);
      			}
      
      			if ($users["$existingUserId"] AND $users["$newUserId"])
      			{
      				// make sure none of these users was deleted while the merge was happening
      				vw_Hard_Core::model('Plugins/Data')->do_user_merge(
      					array(
      						'username' => $oldUserName
      					) + $users["$existingUserId"],
      					array(
      						'username' => $newUserName
      					) + $users["$newUserId"]
      				);
      			}
      		}
      Reply Reply  
    2. June 22, 2017 2:07 PM
      Forsaken Forsaken is offline
      Junior Member
      Thanks, I will probably wait to check this until after we transfer our site to our new server.
      Reply Reply  
    3. June 23, 2017 3:59 AM
      Forsaken Forsaken is offline
      Junior Member
      Tried this on the old server, and am now getting this error:

      Code:
      Fatal error: Unsupported operand types in /home/community/library/vw/XenForo/Model/User.php on line 132
      Reply Reply  
    4. June 23, 2017 9:55 AM
      pegasus pegasus is offline
      VaultWiki Team
      That suggests to me that the source user was already deleted before the merge could be performed. According to the source code, the delete takes place after the merge, so you probably double-clicked the merge button, or another admin deleted that user at the same time you clicked the merge button, or one of the other add-ons involved in the stack trace deleted the user prematurely. I will add some protection against this for the next release. If either user is detected as deleted before completing the merge, the VaultWiki steps will be aborted.
      Reply Reply  
    5. June 26, 2017 2:50 PM
      Forsaken Forsaken is offline
      Junior Member
      Quote Originally Posted by pegasus
      That suggests to me that the source user was already deleted before the merge could be performed. According to the source code, the delete takes place after the merge, so you probably double-clicked the merge button, or another admin deleted that user at the same time you clicked the merge button, or one of the other add-ons involved in the stack trace deleted the user prematurely. I will add some protection against this for the next release. If either user is detected as deleted before completing the merge, the VaultWiki steps will be aborted.
      The users weren't deleted; it happens with merging, or with deleting spam from users awaiting validation.

      After applying your fix I get the following error when doing most actions regarding users:

      Code:
      ErrorException: Fatal Error: Unsupported operand types - library/vw/XenForo/Model/User.php:132
      Updating user moderation queue:

      Code:
      array(3) {
        ["url"] => string(64) "http://community.adeptgamer.com/admin.php?users/moderated/update"
        ["_GET"] => array(1) {
          ["users/moderated/update"] => string(0) ""
        }
        ["_POST"] => array(2) {
          ["users"] => array(1) {
            [1950] => array(2) {
              ["action"] => string(6) "reject"
              ["reject_reason"] => string(0) ""
            }
          }
          ["_xfToken"] => string(8) "********"
        }
      }
      Deleting user from queue:

      Code:
      array(3) {
        ["url"] => string(67) "http://community.adeptgamer.com/admin.php?users/ugecoha.1950/delete"
        ["_GET"] => array(1) {
          ["users/ugecoha_1950/delete"] => string(0) ""
        }
        ["_POST"] => array(2) {
          ["_xfConfirm"] => string(1) "1"
          ["_xfToken"] => string(8) "********"
        }
      }
      Merging users through Admin CP:

      Code:
      array(3) {
        ["url"] => string(64) "http://community.adeptgamer.com/admin.php?users/larka.1557/merge"
        ["_GET"] => array(1) {
          ["users/larka_1557/merge"] => string(0) ""
        }
        ["_POST"] => array(3) {
          ["username"] => string(7) "Yuuyake"
          ["_xfConfirm"] => string(1) "1"
          ["_xfToken"] => string(8) "********"
        }
      }
      I'm just going to disable the wiki for now as I can't have this many errors when doing core functionality on the forum.
      Reply Reply  
    6. June 27, 2017 9:31 AM
      pegasus pegasus is offline
      VaultWiki Team
      Indeed, in all three cases, now that I look more closely, a user gets deleted.

      When rejecting a moderated user, the user is deleted.
      When deleting a user, the user is deleted.
      When merging a user, the original user is deleted. This triggers a second call to changeContentUser that was unexpected.

      When I gave you the replacement code above, it did not consider that the user-delete process would also trigger changeContentUser. Please refer to the new edits above, which should resolve the merge issue without also creating a new issue for deletes.

      I was able to delete a user successfully, without any error logged, while the new code was in place.
      Reply Reply  
    7. June 28, 2017 3:52 AM
      Forsaken Forsaken is offline
      Junior Member
      Everything seems to be fixed now; was able to merge accounts which was one of the primary concerns I had.
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 5:51 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.