akagibi / myfavicon

CraftCMS plugin generating favicon.
MIT License
3 stars 1 forks source link

Server Error on Save and Depreciation Notice #2

Open moondawg69 opened 5 years ago

moondawg69 commented 5 years ago

Two installs, just to check but the same issue when saving a 600x600 png file.

1st thing I noticed, depreciation notice appeared:

The “localeEnabled” element query param has been deprecated. Use “enabledForSite” instead.

Checked the storage folder, logs show:

2019-06-22 21:18:49 [-][1][1b8d202d77d383b2ba480f2c4d7fe4ed][error][yii\base\ErrorException:2] yii\base\ErrorException: imagecreatefrompng(/home/website/public_htmlhttps://www.awebsite.co.uk/siteimages/cc.png): failed to open stream: No such file or directory in /home/website/craft/vendor/akagibi/myfavicon/src/MyFavicon.php:131 Stack trace:

0 /home/website/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(2, 'imagecreatefrom...', '/home/website...', 131)

1 [internal function]: craft\web\ErrorHandler->handleError(2, 'imagecreatefrom...', '/home/website...', 131, Array)

2 /home/website/craft/vendor/akagibi/myfavicon/src/MyFavicon.php(131): imagecreatefrompng('/home/website...')

3 /home/website/craft/vendor/akagibi/myfavicon/src/MyFavicon.php(88): akagibi\myfavicon\MyFavicon->createThumb('png', '/home/website...', '/home/website...', 36, 36, 'android-icon-36...')

4 /home/website/craft/vendor/craftcms/cms/src/services/Plugins.php(704): akagibi\myfavicon\MyFavicon->afterSaveSettings()

5 /home/website/craft/vendor/craftcms/cms/src/controllers/PluginsController.php(171): craft\services\Plugins->savePluginSettings(Object(akagibi\myfavicon\MyFavicon), Array)

6 [internal function]: craft\controllers\PluginsController->actionSavePluginSettings()

7 /home/website/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

8 /home/website/craft/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

9 /home/website/craft/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('save-plugin-set...', Array)

10 /home/website/craft/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-plugin-set...', Array)

11 /home/website/craft/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('plugins/save-pl...', Array)

12 /home/website/craft/vendor/craftcms/cms/src/web/Application.php(565): craft\web\Application->runAction('plugins/save-pl...', Array)

13 /home/website/craft/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest(Object(craft\web\Request))

14 /home/website/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))

15 /home/website/public_html/index.php(24): yii\base\Application->run()

16 {main}

2019-06-22 21:18:49 [-][1][1b8d202d77d383b2ba480f2c4d7fe4ed][info][application] $_GET = [ 'p' => 'admin/settings/plugins/myfavicon' ]

Environment:

PHP version 7.2.19

MySQL 10.2.24 Imagick 3.4.3 (ImageMagick 6.9.4-10) Craft Solo 3.1.31

Hope that helps with the beta testing.

AlexFUNBIT commented 3 years ago
Application Info
PHP version 7.4.16
OS version Linux 4.14.169-0.8.3
Database driver & version MySQL 8.0.21
Image driver & version GD 7.4.16
Craft edition & version Craft Solo 3.7.20
Yii version 2.0.43
Twig version v2.14.7
Guzzle version 7.4.0

Deprecation Warning

image

Stack Trace

Trace Error
12 Deprecation error: The localeEnabled element query param has been deprecated. status() should be used instead., Called from /vol/site/build0/vendor/craftcms/cms/src/elements/db/ElementQuery.php:552
11 craft\elements\db\AssetQuery::__set("localeEnabled", null), Called from /vol/site/build0/vendor/craftcms/cms/src/elements/db/AssetQuery.php:238
10 craft\elements\db\AssetQuery::__set("localeEnabled", null), Called from /vol/site/build0/vendor/yiisoft/yii2/BaseYii.php:558
9 yii\BaseYii::configure(craft\elements\db\AssetQuery, ["siteId" => 1, "search" => null, "offset" => 0, "limit" => 100, ...]), Called from /vol/site/build0/vendor/craftcms/cms/src/controllers/ElementIndexesController.php:458
8 craft\controllers\ElementIndexesController::elementQuery(), Called from /vol/site/build0/vendor/craftcms/cms/src/controllers/ElementIndexesController.php:102
7 craft\controllers\ElementIndexesController::beforeAction(yii\base\InlineAction), Called from /vol/site/build0/vendor/yiisoft/yii2/base/Controller.php:179
6 craft\controllers\ElementIndexesController::runAction("get-elements", ["p" => "admin/actions/element-indexes/get-elements", "v" => "1637028901284"]), Called from /vol/site/build0/vendor/yiisoft/yii2/base/Module.php:534
5 craft\web\Application::runAction("element-indexes/get-elements", ["p" => "admin/actions/element-indexes/get-elements", "v" => "1637028901284"]), Called from /vol/site/build0/vendor/craftcms/cms/src/web/Application.php:287
4 craft\web\Application::runAction("element-indexes/get-elements", ["p" => "admin/actions/element-indexes/get-elements", "v" => "1637028901284"]) Called from /vol/site/build0/vendor/craftcms/cms/src/web/Application.php:596
3 craft\web\Application::_processActionRequest(craft\web\Request), Called from /vol/site/build0/vendor/craftcms/cms/src/web/Application.php:266
2 craft\web\Application::handleRequest(craft\web\Request), Called from /vol/site/build0/vendor/yiisoft/yii2/base/Application.php:392
1 craft\web\Application::run() Called from /vol/site/build0/web/index.php:22

Suggestion

There should be instructions on image upload field (favicon), that image must be uploaded to an asset pointing to a folder on server (@webroot). Otherwise you get fatal error on save.

Fix

Source: MyFavicon.php line 49-67

On line: 61 - Change criteria to status('enabled') ?
Doc: https://docs.craftcms.com/api/v3/craft-elements-asset.html

{
        $view = Craft::$app->getView();

        return $view->renderTemplate('myfavicon/settings', [
            'settings' => $this->getSettings(),
            'myAssetSelectConfig' => array(
                'id'                 => 'myAsset',
                'name'               => 'myAsset',
                'jsClass'            => 'Craft.AssetSelectInput',
                'elementType'        => 'craft\\elements\\Asset',
                'elements'           => $this->getSettings()['myAsset'] && count($this->getSettings()['myAsset']) ? [Craft::$app->getElements()->getElementById($this->getSettings()['myAsset'][0])] : null,
                //'sources'            => array('folder:1'),
                'criteria'           => array('kind' => array('image'), status('enabled') => null),
                'limit'              => 1,
                'viewMode'           => 'table',
                'selectionLabel'     => Craft::t('app','Select image'),
            ),
        ]);
    }