Fixed revertToHistory does not check that content exists

Xon

Well-known member
Affected version
2.1.5
PHP:
public function revertToHistory(\XF\Entity\EditHistory $history, \XF\Mvc\Entity\Entity $content = null, \XF\EditHistory\AbstractHandler $handler = null)
{
   $handler = $handler ?: $this->getEditHistoryHandler($history->content_type);
   $content = $content ?: $handler->getContent($history->content_id);
...
   if ($count && $handler->revertToVersion($content, $history, $previous))

There is no null check on $content to handle case where edit history has been added but not cleaned up correctly when the content is hard deleted.
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.6).

Change log:
Check that we do actually have some valid content before we start working with it, and bug out if not
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom