Sommerregen / grav-plugin-smileys

This plugin substitutes text emoticons, also known as smilies like :-), with images.
Other
3 stars 2 forks source link

undefined index #3

Closed neosin closed 8 years ago

neosin commented 8 years ago

Hello when I install and activate this plugin I get the following error

[2015-11-11 17:15:46] grav.CRITICAL: Undefined index: enabled - Trace: #0 C:\xampp\htdocs\__mynews\grav\user\plugins\smileys\classes\Smileys.php(202): Whoops\Run->handleError(8, 'Undefined index...', 'C:\xampp\htdocs...', 202, Array) #1 C:\xampp\htdocs\__mynews\grav\user\plugins\smileys\classes\Smileys.php(80): Grav\Plugin\Smileys->load('simple_smileys', 'C:/xampp/htdocs...') #2 C:\xampp\htdocs\__mynews\grav\user\plugins\smileys\smileys.php(237): Grav\Plugin\Smileys->__construct('simple_smileys', 'C:/xampp/htdocs...') #3 C:\xampp\htdocs\__mynews\grav\user\plugins\smileys\smileys.php(113): Grav\Plugin\SmileysPlugin->init() #4 [internal function]: Grav\Plugin\SmileysPlugin->onPageContentProcessed(Object(RocketTheme\Toolbox\Event\Event), 'onPageContentPr...', Object(RocketTheme\Toolbox\Event\EventDispatcher)) #5 C:\xampp\htdocs\__mynews\grav\vendor\symfony\event-dispatcher\EventDispatcher.php(160): call_user_func(Array, Object(RocketTheme\Toolbox\Event\Event), 'onPageContentPr...', Object(RocketTheme\Toolbox\Event\EventDispatcher)) #6 C:\xampp\htdocs\__mynews\grav\vendor\symfony\event-dispatcher\EventDispatcher.php(48): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'onPageContentPr...', Object(RocketTheme\Toolbox\Event\Event)) #7 C:\xampp\htdocs\__mynews\grav\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php(23): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('onPageContentPr...', Object(RocketTheme\Toolbox\Event\Event)) #8 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Grav.php(406): RocketTheme\Toolbox\Event\EventDispatcher->dispatch('onPageContentPr...', Object(RocketTheme\Toolbox\Event\Event)) #9 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Page\Page.php(584): Grav\Common\Grav->fireEvent('onPageContentPr...', Object(RocketTheme\Toolbox\Event\Event)) #10 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Page\Page.php(514): Grav\Common\Page\Page->cachePageContent() #11 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Twig\Twig.php(302): Grav\Common\Page\Page->content() #12 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Grav.php(157): Grav\Common\Twig\Twig->processSite(NULL) #13 C:\xampp\htdocs\__mynews\grav\vendor\pimple\pimple\src\Pimple\Container.php(113): Grav\Common\Grav::Grav\Common\{closure}(Object(Grav\Common\Grav)) #14 C:\xampp\htdocs\__mynews\grav\system\src\Grav\Common\Grav.php(255): Pimple\Container->offsetGet('output') #15 C:\xampp\htdocs\__mynews\grav\index.php(37): Grav\Common\Grav->process() #16 {main} [] []

Sommerregen commented 8 years ago

Well, the error points to L202 of the Smileys class and it seems you are using Simple Smileys. However your error means, that some smiley icons have some attributes missing (more probably in your case the enabled option, see here https://github.com/Sommerregen/grav-plugin-smileys/blob/master/assets/packs/simple_smileys/simple_smileys.yaml#L11-L14).

Can you check that simple_smileys.yaml is located in your user/data/smileys/simple_smileys folder with the content of https://github.com/Sommerregen/grav-plugin-smileys/blob/master/assets/packs/simple_smileys/simple_smileys.yaml ?

amamh commented 8 years ago

@Sommerregen

I'm getting a similar error, and yes my user/data/smileys/simple_smileys contains the same simple_smileys.yaml as https://github.com/Sommerregen/grav-plugin-smileys/blob/master/assets/packs/simple_smileys/simple_smileys.yaml

All the simleys in that file have the "enabled" attribute.

Here is a copy of the exception:

    Whoops\Exception\ErrorException thrown with message "Undefined index: enabled"

    Stacktrace:
    #16 Whoops\Exception\ErrorException in /var/www/html/grav-admin/user/plugins/smileys/classes/Smileys.php:202
    #15 Whoops\Run:handleError in /var/www/html/grav-admin/user/plugins/smileys/classes/Smileys.php:202
    #14 Grav\Plugin\Smileys:load in /var/www/html/grav-admin/user/plugins/smileys/classes/Smileys.php:80
    #13 Grav\Plugin\Smileys:__construct in /var/www/html/grav-admin/user/plugins/smileys/smileys.php:237
    #12 Grav\Plugin\SmileysPlugin:init in /var/www/html/grav-admin/user/plugins/smileys/smileys.php:113
    #11 Grav\Plugin\SmileysPlugin:onPageContentProcessed in <#unknown>:0
    #10 call_user_func in /var/www/html/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:160
    #9 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /var/www/html/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:48
    #8 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /var/www/html/grav-admin/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
    #7 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /var/www/html/grav-admin/system/src/Grav/Common/Grav.php:406
    #6 Grav\Common\Grav:fireEvent in /var/www/html/grav-admin/system/src/Grav/Common/Page/Page.php:584
    #5 Grav\Common\Page\Page:cachePageContent in /var/www/html/grav-admin/system/src/Grav/Common/Page/Page.php:514
    #4 Grav\Common\Page\Page:content in /var/www/html/grav-admin/system/src/Grav/Common/Twig/Twig.php:302
    #3 Grav\Common\Twig\Twig:processSite in /var/www/html/grav-admin/system/src/Grav/Common/Grav.php:157
    #2 Grav\Common\Grav:Grav\Common\{closure} in /var/www/html/grav-admin/vendor/pimple/pimple/src/Pimple/Container.php:113
    #1 Pimple\Container:offsetGet in /var/www/html/grav-admin/system/src/Grav/Common/Grav.php:255
    #0 Grav\Common\Grav:process in /var/www/html/grav-admin/index.php:37
Sommerregen commented 8 years ago

Ok @amamh thank you. I will investigate it further.

UPDATE: Ok, it seems like I haven't considered all cases. A quick fix is to modify Smileys.php at L198-202 to

$enabled = isset($smiley['enabled']) ? $smiley['enabled'] : false;

// Filter out files, disabled smileys and smiley icons not in
// list of valid image extensions
if (!in_array($image->get('extension'), $ext) || $enabled) {

and tell me whether this works or not.

amamh commented 8 years ago

@Sommerregen

Thanks, my friend. That worked but it should be !$enabled :)

Sommerregen commented 8 years ago

Thanks for all of you!