Gossamer
Active member
I'm currently working on an add-on that is supposed to take the recently posted post_id and post_date and store it in an array on a particular field of the xf_user table. I'm trying to serialize the array, but I keep getting an error when I try to unserialize it.
Here is what I have so far:
User Model
User Datawriter
I keep getting this error:
Any ideas?
Here is what I have so far:
User Model
PHP:
public function getActivityPosts($userId)
{
$posts = $this->_getDb()->fetchOne('
SELECT rp_messages_for_activity AS posts
FROM xf_user
WHERE user_id = ?
', $userId);
return $posts;
}
User Datawriter
PHP:
public function updateTrackedActivityPosts($userId, $postid, $postdate)
{
/* Get current activity posts from database */
$activityPosts = $this->_getUserModel()->getActivityPosts($userId);
/* Unserialize data */
$activityPosts = unserialize($activityPosts);
/* Add new entry to activityPosts */
$activityPosts[$postid] = $postdate;
/* Serialize data */
$activityPosts = serialize($activityPosts);
$this->set('rp_messages_for_activity', $activityPosts);
}
I keep getting this error:
unserialize(): Error at offset 0 of 2 bytes
- XenForo_Application::handlePhpError()
- unserialize() in Goss/RoleplaySystem/DataWriter/User.php at line 23
- Goss_RoleplaySystem_DataWriter_User->updateTrackedActivityPosts() in Goss/RoleplaySystem/DataWriter/DiscussionMessage/Post.php at line 53
- Goss_RoleplaySystem_DataWriter_DiscussionMessage_Post->_updateUserPostsForActivity() in Goss/RoleplaySystem/DataWriter/DiscussionMessage/Post.php at line 10
- Goss_RoleplaySystem_DataWriter_DiscussionMessage_Post->_messagePostSave() in XenForo/DataWriter/DiscussionMessage.php at line 589
- XenForo_DataWriter_DiscussionMessage->_postSave() in XenForo/DataWriter.php at line 1423
- XenForo_DataWriter->save() in XenForo/ControllerPublic/Thread.php at line 578
- XenForo_ControllerPublic_Thread->actionAddReply() in XenForo/FrontController.php at line 351
- XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
- XenForo_FrontController->run() in C:/xampp/htdocs/xenforo_DEV/index.php at line 13
Any ideas?