The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Better Related Posts
Embedcode post causing: 'Warning: array_keys()' (5 posts)

  1. Twansparant
    Posted 4 years ago #

    Hi there,

    I'm getting some weird PHP warnings with the better-related-posts plugin: http://wordpress.org/extend/plugins/better-related/ but only on ONE particular post.

    I have been using the plugin without any problems for some months now, but all of sudden these warnings showed up on my single template:

    Warning: array_keys() [function.array-keys]: The first argument should be an array in /path-to/single.php on line 69
    Warning: array_slice() expects parameter 1 to be array, null given in /path-to/single.php on line 69
    Warning: array_search() [function.array-search]: Wrong datatype for second argument in /path-to/single.php on line 79


    However, the related posts DO show up underneath these warnings with my custom query like this: http://pastebin.com/JacTv2mZ
    (line 69 from the warnings is line 2 in pastebin)

    So I tried to pindown the problem and it seems it's only occuring when there is a <object> embedding in the post content like a soundcloud player in my case.

    If I replace this original soundcloud embedcode with a shortcode (using this plugin):
    [soundcloud params="player_type=tiny&color=006F9F" height="18"]http://soundcloud.com/trackname[/soundcloud] the warnings are gone.

    My guess is that this embeddingcode is being included in the MySQL Fulltext Search and causing problems, but I think it should be excluded?

    Does anyone have similar problems or have a solution or workaround for my problem? Any help is appreciated!

    Thank you!

  2. Twansparant
    Posted 4 years ago #

    Even with the new HTML5 soundcloud code using iframes the problem occurs.

  3. blackbookdesign
    Posted 4 years ago #

    Did you find a solution for this?
    I have the same problem...

  4. Twansparant
    Posted 4 years ago #

    No unfortunately not yet...
    I have a workaround though to check if $scores returns an array, if not I use the normal the_related

    I allready addressed the issue to the plugin author here:

  5. blackbookdesign
    Posted 4 years ago #

    Great. Thanks for the hint.

    On my side I've found a sneakier way to "mask" the bug.
    I actually turned off the php errors display in the wp-config.
    SInce I was pushing the site into production I needed a quick solution.
    While it will makes the error log grow, it still make it a viable solution.
    + it still shows the other related while clearing the array slice error.
    if interested:

    @ini_set('display_errors', 0);

    On my side the error was done using the integrated WP embed for youtube.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Better Related Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic