Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when using TOC with Grav 1.1: array_keys() expects parameter 1 to be array, string given #13

Closed
magnetik opened this issue Jul 29, 2016 · 5 comments

Comments

@magnetik
Copy link

Using grav 1.1 and latest available version.

Got the exception:


Whoops\Exception\ErrorException thrown with message "array_keys() expects parameter 1 to be array, string given"

Stacktrace:
#24 Whoops\Exception\ErrorException in /vagrant/lab/user/plugins/toc/classes/Toc.php:440
#23 array_keys in /vagrant/lab/user/plugins/toc/classes/Toc.php:440
#22 Grav\Plugin\Toc:hyphenize in /vagrant/lab/user/plugins/toc/classes/Toc.php:113
#21 Grav\Plugin\Toc:createToc in /vagrant/lab/user/plugins/toc/classes/Toc.php:254
#20 Grav\Plugin\Toc:render in /vagrant/lab/user/plugins/toc/toc.php:161
#19 Grav\Plugin\TocPlugin:tocFilter in /vagrant/lab/user/plugins/toc/toc.php:111
#18 Grav\Plugin\TocPlugin:onPageContentProcessed in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#17 call_user_func in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#16 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:46
#15 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /vagrant/lab/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#14 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /vagrant/lab/system/src/Grav/Common/Grav.php:297
#13 Grav\Common\Grav:fireEvent in /vagrant/lab/system/src/Grav/Common/Page/Page.php:588
#12 Grav\Common\Page\Page:content in /vagrant/lab/user/plugins/shortcode-core/shortcode-core.php:136
#11 Grav\Plugin\ShortcodeCorePlugin:onPageInitialized in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#10 call_user_func in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#9 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /vagrant/lab/vendor/symfony/event-dispatcher/EventDispatcher.php:46
#8 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /vagrant/lab/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#7 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /vagrant/lab/system/src/Grav/Common/Grav.php:297
#6 Grav\Common\Grav:fireEvent in /vagrant/lab/system/src/Grav/Common/Processors/PagesProcessor.php:19
#5 Grav\Common\Processors\PagesProcessor:process in /vagrant/lab/system/src/Grav/Common/Grav.php:121
#4 Grav\Common\Grav:Grav\Common\{closure} in /vagrant/lab/system/src/Grav/Common/Grav.php:383
#3 Grav\Common\Grav:Grav\Common\{closure} in /vagrant/lab/system/src/Grav/Common/Grav.php:359
#2 call_user_func_array in /vagrant/lab/system/src/Grav/Common/Grav.php:359
#1 Grav\Common\Grav:__call in /vagrant/lab/system/src/Grav/Common/Grav.php:122
#0 Grav\Common\Grav:process in /vagrant/lab/index.php:45

@muflone
Copy link

muflone commented Aug 27, 2016

The same happens to me whenever I add some custom header tag in the page frontmatter like

star_ratings:
    disabled: true

@muflone
Copy link

muflone commented Aug 31, 2016

In the meantime I've made a workaround:

    if (is_array($replacements))
        $text = preg_replace(array_keys($replacements), $replacements, $text);

@magnetik
Copy link
Author

magnetik commented Sep 1, 2016

Maybe if you do a pull request it will be merged. Thanks for sharing your workaround anyway !

@take4mats
Copy link

The same happened to me, and I applied the workaround by @muflone to "classes/Toc.php" line 440.
Now it works well. Thanks and hope this fix to be merged!

hruoho added a commit to hruoho/grav-plugin-toc that referenced this issue Sep 30, 2016
@Sommerregen
Copy link
Owner

Thanks guys I have merged it. Will fix some other bugs before next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants