Fixed Database transaction issue in XF\Service\User\Downgrade

xfrocks

Well-known member
Affected version
2.0.0 Beta 8
In method `downgrade` below, the transaction is started and leave there on the premature `return false`.

PHP:
	public function downgrade()
	{
		$user = $this->user;
		$upgrade = $this->userUpgrade;
		$active = $this->activeUpgrade;
		$expired = $this->expiredUpgrade;

		$db = $this->db();
		$db->beginTransaction();

		/** @var UserGroupChange $userGroupChange */
		$userGroupChange = $this->service('XF:User\UserGroupChange');
		$userGroupChange->removeUserGroupChange(
			$user->user_id, 'userUpgrade-' . $upgrade->user_upgrade_id
		);

		if (!$active)
		{
			return false;
		}

		...
	}

Maybe we should do a rollback first?
 
In this situation, we shouldn't actually be returning here, just not doing certain work. If we trigger a downgrade, we need to make sure the user groups are removed regardless of the other state.
 
Back
Top Bottom