Fixed PHP 8 compatibility: [E_WARNING] Attempt to read property "height" on null

420

Active member
Affected version
2.2.10 Patch 1
Happens on both PHP 8.0 and 8.1.

After upgrading from PHP 7.4 to PHP 8.1, a bunch of errors started popping up in the Server Error Log. Downgrading to 8.0 and rebuilding master data didn't help. Disabling all addons didn't help.

We have over 1,854,562 images in our Media Galley. Whenever the problematic media gallery item is viewed, it triggers the error without fail. The affected media gallery images are broken. This only started happening after upgrading to PHP 8.

Errors:
I've edited out the URL title and changed the name of /home/user/.

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "height" on null src/addons/XFMG/Entity/MediaItem.php:997
Generated by: Unknown account Aug 26, 2022 at 11:22 AM
Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(997): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/420/do...', 997)
#1 src/XF/Mvc/Entity/Entity.php(162): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(120): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l1/s3/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#5 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('xfmg_media_view', Array)
#6 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#7 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#8 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#11 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#12 src/XF.php(524): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
Request state
array(4) {
  ["url"] => string(39) "/community/gallery/1452046/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "Data" on null src/addons/XFMG/Entity/MediaItem.php:997
Generated by: Unknown account Aug 26, 2022 at 11:22 AM
Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(997): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/420/do...', 997)
#1 src/XF/Mvc/Entity/Entity.php(162): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(120): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l1/s3/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#5 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('xfmg_media_view', Array)
#6 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#7 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#8 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#11 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#12 src/XF.php(524): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
Request state
array(4) {
  ["url"] => string(39) "/community/gallery/41452046/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "width" on null src/addons/XFMG/Entity/MediaItem.php:993
Generated by: Unknown account Aug 26, 2022 at 11:22 AM
Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(993): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/420/do...', 993)
#1 src/XF/Mvc/Entity/Entity.php(162): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(120): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l1/s3/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#5 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('xfmg_media_view', Array)
#6 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#7 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#8 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#11 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#12 src/XF.php(524): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
Request state
array(4) {
  ["url"] => string(39) "/community/gallery/1452046/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "Data" on null src/addons/XFMG/Entity/MediaItem.php:993
Generated by: Unknown account Aug 26, 2022 at 11:22 AM
Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(993): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/420/do...', 993)
#1 src/XF/Mvc/Entity/Entity.php(162): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(120): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l1/s3/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#5 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('xfmg_media_view', Array)
#6 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#7 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#8 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#11 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#12 src/XF.php(524): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
Request state
array(4) {
  ["url"] => string(39) "/community/gallery/1452046/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "extension" on null src/addons/XFMG/Entity/MediaItem.php:990
Generated by: Unknown account Aug 26, 2022 at 11:22 AM
Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(990): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/420/do...', 990)
#1 src/XF/Mvc/Entity/Entity.php(162): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(120): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l1/s3/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#5 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('xfmg_media_view', Array)
#6 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#7 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#8 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#11 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#12 src/XF.php(524): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
Request state
array(4) {
  ["url"] => string(39) "/community/gallery/1452046/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

More reports similar to this issue:

Similar error report unrelated to XFMG:
 

XF Bug Bot

XenForo bug fixer bot
Staff member
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 XFMG release (2.2.5).

Change log:
Avoid error logs if there is a non-existent attachment for a media item.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top