XCentral
Well-known member
Hello,
We got a report from one of our customers regarding an SQL error when copying a post. Troubleshooting the issue we found that it is caused because of XenForo_Model_Post::_copyPost method doing database insert call using the $post array it gets as an argument. However, this array is gathered by XenForo_Model_Post::getPostsAndParentData method which internally calls XenForo_Model_Post::getPostsByIds. This last method is meant to be extended by third-party add-ons to join new tables and get new information from their own tables by overriding XenForo_Model_Post:: preparePostJoinOptions used by this method.
So our add-on joins its own table and adds some variables to the returned post array, causing the error reported.
After reproducing the issue we saw it causes problems with some other add-ons as well, e.g. XFA - Better Blogs.
We have implemented a temporary fix by overriding XenForo_Model_Post::getPostsAndParentData method (which seems to be used for inline moderation actions only so far) and removing the keys from the posts which are not found in xf_post table, using $db->describeTable call.
Please let us know your thoughts or if you need any further information.
Thank you!
We got a report from one of our customers regarding an SQL error when copying a post. Troubleshooting the issue we found that it is caused because of XenForo_Model_Post::_copyPost method doing database insert call using the $post array it gets as an argument. However, this array is gathered by XenForo_Model_Post::getPostsAndParentData method which internally calls XenForo_Model_Post::getPostsByIds. This last method is meant to be extended by third-party add-ons to join new tables and get new information from their own tables by overriding XenForo_Model_Post:: preparePostJoinOptions used by this method.
So our add-on joins its own table and adds some variables to the returned post array, causing the error reported.
After reproducing the issue we saw it causes problems with some other add-ons as well, e.g. XFA - Better Blogs.
We have implemented a temporary fix by overriding XenForo_Model_Post::getPostsAndParentData method (which seems to be used for inline moderation actions only so far) and removing the keys from the posts which are not found in xf_post table, using $db->describeTable call.
Please let us know your thoughts or if you need any further information.
Thank you!
Last edited: