Fixed [E_WARNING] Invalid argument supplied for foreach()

rfc0001

Well-known member
Been getting this error a couple times a day the last two days always on the same threads. Says user unknown so can't follow up to find out what the repro was.

Stack trace
#0 src/addons/XFMG/Repository/Media.php(579): XF::handlePhpError(2, '[E_WARNING] Inv...', '/home/dvcinfo1/...', 579, Array)
#1 src/addons/XFMG/XF/Pub/Controller/Thread.php(16): XFMG\Repository\Media->addGalleryEmbedsToContent(NULL)
#2 src/XF/Mvc/Dispatcher.php(249): XFMG\XF\Pub\Controller\Thread->actionIndex(Object(XF\Mvc\ParameterBag))
#3 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'Index', 'html', Object(XF\Mvc\ParameterBag), 'forums', Object(XFMG\XF\Pub\Controller\Thread), NULL)
#4 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#5 src/XF/App.php(1880): XF\Mvc\Dispatcher->run()
#6 src/XF.php(328): XF\App->run()
#7 index.php(13): XF::runApp('XF\\Pub\\App')
#8 {main}

Request state
array(4) {
["url"] => string(77) "/forum/threads/threadname.1234/"
["referrer"] => bool(false)
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}

Any ideas what might be causing this?
 
This appears to not be a MG Exception, it's just getting caught by MG. If you search this same error on the entire forum, you'll find it in relation to several add-on errors as well, so seems to just be an exception handler that is catching some downstream exceptions (not sure if that is by design/desirable/avoidable).

In my case, I manually restored some threads and was missing the xf_thread_redirect table entries for these threads. Restored those and no longer getting these errors.
 
Last edited:
It should be easy to prevent this from triggering though -- we need to check whether the reply has the data we need.

Thus, moving to bugs.
 
Top Bottom