verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Deprecated Function Warning in PHP 8.2 for pathinfo() #84

Closed satheesht closed 6 months ago

satheesht commented 7 months ago

Describe the bug

After upgrading from PHP 8.0 to PHP 8.2, I encountered a deprecation warning in the Icon Picker plugin for Craft CMS. The warning is triggered by passing a null value to the pathinfo() function in the Icon.php file.

Array
(
    [short] => Warning occurred
    [full] => pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated
    [data] => Array
        (
            [stack_trace] => #0 [internal function]: pipedrive\craftlogger\handlers\ErrorHandler->handleError(8192, 'pathinfo(): Pas...', '/app/vendor/ver...', 139)
#1 /app/vendor/verbb/icon-picker/src/models/Icon.php(139): pathinfo(NULL, 8)
#2 /app/vendor/verbb/icon-picker/src/models/Icon.php(151): verbb\iconpicker\models\Icon->getLabel()
#3 /app/vendor/verbb/icon-picker/src/models/Icon.php(75): verbb\iconpicker\models\Icon->getKeywords()
#4 /app/vendor/yiisoft/yii2/base/BaseObject.php(109): verbb\iconpicker\models\Icon->init()
#5 /app/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#6 /app/vendor/verbb/icon-picker/src/models/Icon.php(53): craft\base\Model->__construct(Array)
#7 /app/vendor/verbb/icon-picker/src/fields/IconPickerField.php(130): verbb\iconpicker\models\Icon->__construct(Array)
#8 /app/vendor/craftcms/cms/src/base/Element.php(5306): verbb\iconpicker\fields\IconPickerField->normalizeValue(Array, Object(benf\neo\elements\Block))
#9 /app/vendor/craftcms/cms/src/base/Element.php(4167): craft\base\Element->normalizeFieldValue('icon_name')
#10 /app/vendor/craftcms/cms/src/base/Element.php(2497): craft\base\Element->getFieldValue('icon_name')
#11 /app/vendor/yiisoft/yii2/base/Model.php(370): craft\base\Element->afterValidate()
#12 /app/vendor/craftcms/cms/src/base/Element.php(2452): yii\base\Model->validate(Array, true)
#13 /app/vendor/spicyweb/craft-neo/src/elements/Block.php(276): craft\base\Element->validate(NULL, true)
#14 /app/vendor/spicyweb/craft-neo/src/Field.php(854): benf\neo\elements\Block->validate()
#15 /app/vendor/craftcms/cms/src/base/Element.php(2602): benf\neo\Field->validateBlocks(Object(craft\elements\Entry), NULL)
#16 /app/vendor/yiisoft/yii2/validators/InlineValidator.php(77): craft\base\Element->validateCustomFieldAttribute('field:contentBu...', Array, Object(yii\validators\InlineValidator), Object(benf\neo\elements\db\BlockQuery))
#17 /app/vendor/yiisoft/yii2/validators/Validator.php(260): yii\validators\InlineValidator->validateAttribute(Object(craft\elements\Entry), 'field:contentBu...')
#18 /app/vendor/craftcms/cms/src/base/Element.php(2491): yii\validators\Validator->validateAttributes(Object(craft\elements\Entry))
#19 /app/vendor/yiisoft/yii2/base/Model.php(370): craft\base\Element->afterValidate()
#20 /app/vendor/craftcms/cms/src/base/Element.php(2452): yii\base\Model->validate(Array, true)
#21 /app/vendor/craftcms/cms/src/services/Elements.php(3226): craft\base\Element->validate(NULL)
#22 /app/vendor/craftcms/cms/src/services/Elements.php(1362): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, true, false, Array, false)
#23 /app/vendor/craftcms/cms/src/console/controllers/ResaveController.php(619): craft\services\Elements->resaveElements(Object(craft\elements\db\EntryQuery), true, true, false, false)
#24 /app/vendor/craftcms/cms/src/console/controllers/ResaveController.php(463): craft\console\controllers\ResaveController->_resaveElements(Object(craft\elements\db\EntryQuery))
#25 /app/vendor/craftcms/cms/src/console/controllers/ResaveController.php(380): craft\console\controllers\ResaveController->resaveElements('craft\\elements\\...', Array)
#26 [internal function]: craft\console\controllers\ResaveController->actionEntries()
#27 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#28 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#29 /app/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('entries', Array)
#30 /app/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('entries', Array)
#31 /app/vendor/craftcms/cms/src/console/Controller.php(217): craft\console\Controller->traitRunAction('entries', Array)
#32 /app/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('entries', Array)
#33 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('resave/entries', Array)
#34 /app/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('resave/entries', Array)
#35 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('resave/entries', Array)
#36 /app/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#37 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#38 /app/craft(21): yii\base\Application->run()
#39 {main}
            [file] => /app/vendor/verbb/icon-picker/src/models/Icon.php
            [code] => 8192
            [line] => 139
        )

)

Steps to reproduce

  1. Upgrade the PHP version from 8.0 to 8.2.
  2. While resaving one of the craft entries using icon-picker in the field layout
  3. Observe the deprecation warning in the logs or error output.

Craft CMS version

4.5.6.1

Plugin version

2.0.14

Multi-site?

Yes

Additional context

No response

engram-design commented 7 months ago

Fixed for the next release. To get this early, run composer require verbb/icon-picker:"dev-craft-4 as 2.0.15".

satheesht commented 7 months ago

Thank you, @engram-design for the quick fix

engram-design commented 6 months ago

Fixed in 2.0.16