smcyr / Craft-FocusPoint

A plugin for Craft CMS based on jQuery FocusPoint
MIT License
101 stars 6 forks source link

500 error when deleting Assets #19

Closed m8brgarc closed 7 years ago

m8brgarc commented 7 years ago

If I "Clear Imager Transforms" before deleting the Assets I get this error:

PHP Error [500]

Trying to get property of non-object (/var/www/craft/plugins/focuspoint/FocusPointPlugin.php:54)

I temporarily fixed it by checking for the element before doing the conditional on it's elementType:

$element = craft()->elements->getElementById($elementId);
                if($element) {
                    if ($element->elementType === "Asset") {
                        craft()->focusPoint_focusPoint->deleteFocusPointRecordsByAssetId($elementId);
                    } else {
                        craft()->focusPoint_focusPoint->deleteFocusPointRecordsBySourceId($elementId);
                    }
                }
smcyr commented 7 years ago

Thanks for bringing this up, it's fixed in the latest release.