Fixed Can't upload image without error

Affected version
2.0.0 Beta 1
This error appears:

ErrorException: array_keys() expects parameter 1 to be array, null given in src/addons/XFMG/Notifier/Media/CategoryWatch.php at line 70
array_keys() in src/addons/XFMG/Notifier/Media/CategoryWatch.php at line 70
XFMG\Notifier\Media\CategoryWatch->getDefaultNotifyData() in src/XF/Service/AbstractNotifier.php at line 258
XF\Service\AbstractNotifier->ensureDataLoaded() in src/XF/Service/AbstractNotifier.php at line 31
XF\Service\AbstractNotifier->notify() in src/XF/Service/AbstractNotifier.php at line 56
XF\Service\AbstractNotifier->notifyAndEnqueue() in src/addons/XFMG/Service/Media/Creator.php at line 282
XFMG\Service\Media\Creator->sendNotifications() in src/addons/XFMG/Pub/Controller/Media.php at line 664
XFMG\Pub\Controller\Media->finalizeMediaItemCreate() in src/addons/XFMG/Pub/Controller/Media.php at line 741
XFMG\Pub\Controller\Media->actionSaveMedia() in src/XF/Mvc/Dispatcher.php at line 232
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 85
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1771
XF\App->run() in src/XF.php at line 319
XF::runApp() in index.php at line 13


Chris D

XenForo developer
Staff member
Are you uploading to an album or a category?

There was an incomplete fix for this issue yesterday before release.

To fix, edit the file src/addons/XFMG/Notifier/Media/CategoryWatch.php

Line 68 is:
$category = $mediaItem->Category;
Below that add:
if (!$category)
    return [];