Fixed Error on invalid data in Multi Quote local storage

Painbaker

Well-known member
Affected version
2.3.3, 2.2.16
If the user has broken or modified xf_multiQuoteThread local storage data an error like this might occur:

Code:
ErrorException: [E_WARNING] foreach() argument must be of type array|object, string given in src\XF\ControllerPlugin\QuotePlugin.php at line 75

    XF::handlePhpError() in src\XF\ControllerPlugin\QuotePlugin.php at line 75
    XF\ControllerPlugin\QuotePlugin->XF\ControllerPlugin\{closure}()
    array_map() in src\XF\ControllerPlugin\QuotePlugin.php at line 73
    XF\ControllerPlugin\QuotePlugin->prepareQuotes() in src\XF\Pub\Controller\ThreadController.php at line 856
    XF\Pub\Controller\ThreadController->actionMultiQuote() in src\XF\Mvc\Dispatcher.php at line 362
    XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 264
    XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 121
    XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 63
    XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2826
    XF\App->run() in src\XF.php at line 806
    XF::runApp() in index.php at line 23

As there is no is_array validation here:

PHP:
    public function prepareQuotes(array $quotes)
    {
        return array_map(function($quotes)
        {
            foreach ($quotes AS $i => &$quote)
            {
                if ($quote === null)
                {
                    unset($quotes[$i]);
                }
                else if ($quote !== true)
                {
                    $quote = $this->prepareMessage(null, $quote);
                }
            }
            return $quotes;
        }, $quotes);
    }
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.4).

Change log:
Handle invalid multiquote input more gracefully
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom