• Resolved JohnNadeau

    (@johnnadeau)


    Hi Jeremy,

    We have two sites, both running version 1.3.3 successfully since that version’s release (LakePath.com and LeLacAppelle.com)

    We updated to version 1.4.0 on both sites today (Sunday 11/20/16) and it resulted in the error below.

    I tried clearing our Cache (SiteGround SuperCacher at both web sites) & WebBrowser Cache to no avail.

    I then rolled back LakePath to ver 1.3.3 (didn’t even flush the SiteGround cache), and all was well again at LakePath. For consistency, I then rolled back LeLacAppelle to ver 1.3.3.

    Here’s a screenshot of how it works on LakePath with ver 1.3.3: https://snag.gy/1l0zMc.jpg

    ISSUE: On LakePath, in place of the LEFT COLUMN, where the Posts/Images are brought in from LeLacAppelle, here’s the error (repeated for each/every imported post):
    Warning: array_slice() expects parameter 1 to be array, object given in /home/nadeauap/public_html/lakepath/wp-content/plugins/rest-api-post-embeds/rest-api-post-embeds.php on line 326

    Please let me know if you need me to update the plugin to 1.4.0 and/or make any other changes to assist in troubleshooting this issue. Otherwise, I’ll remain at ver 1.3.3 until you advise.

    Thanks in advance for all of your help and insight !

    John

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Could you check that you’re running one of the following on the site you’re pulling posts from?

    Let me know if it helps.

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    No, we’re not running WordPress 4.7 Beta on either site.

    Both sites are running WordPress 4.6.1.

    Both sites are running WP REST API Version 2.0-beta15

    All other plugins are up-to-date (including JetPack).

    Let me know if you have any other questions.

    Thanks,

    John

    Thread Starter JohnNadeau

    (@johnnadeau)

    …edit…

    I see that JetPack just presented a new version 4.4.

    As of yesterday, we were running JetPack Version 4.3.2 on both sites.

    We’ll continue to run the prior JetPack Version 4.3.2 unless you advise otherwise (we normally like to wait 4-5 days before updating any plugin)

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Since you’re querying the WP REST API, the version of Jetpack won’t matter here.

    Could you copy the shortcode you’re using, and paste it here so I can run some more tests?

    Thanks!

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    I have it in a Text Widget:
    [jeherve_post_embed url=”lelacappelle.com” wpapi=true include_images=”true” order_by=”rand” number=”5″ image_size=”202,114″ include_credits=”false” include_excerpt=”false” category=”Lake Moments”]

    Thanks,

    John

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Thanks! I seem to see 2 issues here:

    1. Could you try to update that shortcode and use " instead of , like so:

      [jeherve_post_embed url="lelacappelle.com" wpapi=true include_images="true" order_by="rand" number="5" image_size="202,114" include_credits="false" include_excerpt="false" category="Lake Moments"]

    2. rand might not be supported by the WP REST API anymore. I receive the following error when trying to use that parameter: orderby is not one of date, relevance, id, include, title, slug

    I’ll update my plugin’s documentation to reflect the changes. I’m afraid you’ll need to stop using using order_by="rand" as a shortcode parameter, at least until the parameter is added back to the WP REST API, if it is added back.

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    As to #1: My apologies… when I pasted the code into the prior reply, it converted quotes into smartquotes ?? (I should have inserted it as raw code as you did above). Bottom line, my code is exactly as you posted above.

    As to #2: I had updated WP Rest API within a few days of its release to Version 2.0-beta15. Displaying posts from LeLac inside of LakePath has been working ever since, until upgrading Rest API Post Embeds from 1.3.3 to version 1.4.0: I had not received any error regarding the order_by="rand"

    Now #3 as it may also relate to the original error?:
    You had me add the code below into my Child/Functions.php to cause the posts to refresh after 1 minute, instead of 10. It has been working correctly using WP Rest API v2.0-beta15 and Rest API Post Embeds v1.3.3

    /* JRN Note Changes default cache of 10 minutes to refresh posts */
    function jeherve_custom_api_embeds_caching() {
    	return 1 * MINUTE_IN_SECONDS;
    }
    add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );

    Wrapping up…
    Do you see any issues if we stay on WP Rest API v2.0-beta15 and Rest API Post Embeds v1.3.3? I really like your plugin and this functionality ??

    Thanks for your help!

    John

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    until upgrading Rest API Post Embeds from 1.3.3 to version 1.4.0: I had not received any error regarding the order_by="rand"

    That’s because my plugin hadn’t switched to using the updated API endpoints introduced in the WP REST API plugin, and that will be part of WordPress itself in a few weeks, when WordPress 4.7 is released.

    You could continue to use Rest API Post Embeds v1.3.3 for a bit longer, but on the long term you will run into issues when you’ll want to stop using the WP REST API plugin, and rely on WordPress itself to create the endpoints.

    WordPress itself might change in the future, and start supporting random ordering again. The different ordering parameters will be audited, and may be customized, here:
    https://core.trac.www.ads-software.com/ticket/38693

    I’m sorry that’s not much of an answer, but the changes are still fresh (they were made only a few weeks ago), and I can’t seem to find a great way to add filters back just yet. It seems to be in the works though, so you might be able to add random sorting support back to the API on your site soon.

    I’ll mention it in the plugin readme if that ever changes!

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    I’ve been following the ticket you referenced. I’m a bit unclear as to how to proceed. Can you review the info below, then recommend a course of action?
    For example:
    –Upgrade to 4.7… or wait for 4.7.1… or wait for 4.8 ?
    –Drop or Keep WP REST API plugin
    –Stay on v1.3.3 REST API Post Embeds or Upgrade to 1.4.0

    Our last post in this thread was on 11/23/16 (above).

    The last post in the ticket you referenced was on 12/1/16:
    https://core.trac.www.ads-software.com/ticket/38693.

    Here’s where things stand on LakePath.com:
    –WordPress v4.6.1
    –WP REST API v2.0-beta15
    –REST API Post Embeds v1.3.3
    –(all other plugins updated/current)
    –I’m using a Text Widget in Left Column:
    [jeherve_post_embed url=”lelacappelle.com” wpapi=true include_images=”true” order_by=”rand” number=”5″ image_size=”202,114″ include_credits=”false” include_excerpt=”false” category=”Lake Moments”]
    –I’m using the following filter in my child theme functions.php:

    function jeherve_custom_api_embeds_caching() {
    	return 1 * MINUTE_IN_SECONDS;
    }
    add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );

    As always, I appreciate any help you might provide.

    Thanks!

    John

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Could you try to add the snippet suggested here in your child theme’s functions.php file?

    If it works, I’ll add it to my plugin so we don’t have to wait for a WordPress release for the problem to be fixed.

    Thanks for giving it a try!

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    OK… to be clear, I did not update WordPress or your plugin yet.

    I added the following to my child’s function.php:

    add_filter( 'rest_post_collection_params', 'my_prefix_add_rest_orderby_params', 10, 1 );
    
    function my_prefix_add_rest_orderby_params( $params ) {
        $params['orderby']['enum'][] = 'rand';
    
        return $params;
    }

    It appears to be working, with the exception of refreshing the posts that are displayed. As noted in my prior post, I have a code snippet that overrides the 10 minute refresh to 1 minute. I also tested after 10 minutes, then 20 minutes, but the posts remain the same as they were first displayed.

    Here are the posts that were displayed at 7:32am, and remained the same as of 8:02am (after refreshing the page, or browsing to another page). Posts Displayed

    Seems like this behavior began after updating WP REST API to v2.0-beta15. Or could it be the SiteGround cache (on either LakePath.com or LeLacAppelle.com) ?

    I will leave the new snippet in place and will not update WordPress or your plugin until you advise further.

    Thanks!

    John

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Sorry, I should have been more clear. Let me clarify:

    • This snippet has to be added to the site you’re pulling posts from (lelacappelle.com).
    • lelacappelle.com has to be running WordPress 4.7.
    • LakePath.com should run the latest version of my plugin.

    Once you’ve done that, wait until the data refreshes and you should be all set.

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    Sorry for my absence ??

    I was finally able to update both sites to 4.7.2, all plugins, including your’s, and make the code snippets changes on both sites as well.

    Result: it does pull the posts in randomly, but it does not appear to refresh them… even after 30 minutes.

    These are the code snippets I currently have in Child Functions.php on both sites. Do you have any thoughts/suggestions?:

    /* JRN Note Changes default cache of 10 minutes to refresh posts */
    function jeherve_custom_api_embeds_caching() {
    	return 1 * MINUTE_IN_SECONDS;
    }
    add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );
    
    /* JRN Note Jeremy had me add to fix rand sort */
    
    add_filter( 'rest_post_collection_params', 'my_prefix_add_rest_orderby_params', 10, 1 );
    
    function my_prefix_add_rest_orderby_params( $params ) {
        $params['orderby']['enum'][] = 'rand';
    
        return $params;
    }
    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I wonder if that API request may be cached on your site. Do you use a caching plugin on lelacappelle.com?

    Thread Starter JohnNadeau

    (@johnnadeau)

    Hi Jeremy,

    Yes, I think you identified the issue!

    We use SG SuperCache v2.3.2 on both sites.

    I A/B tested it:
    Loaded LakePath.com page in browser
    Waited 5 minutes
    Shift/Refreshed Webage in browser
    A=No change in displayed posts.
    Purged the SG SuperCache at LeLacAppelle.com
    Shift/Refreshed Webage in browser
    B=New set of posts were displayed.

    Note: SG SuperCache was renamed to SG Optimizer v3.05. As of last night, they were having problems with it causing high CPU usage, so I rolled back and did testing above under v.2.3.2.

    Are there any changes I can make in the code snippet we’re using to force it to bypass the cache, or should I reach out to SiteGround?

    Thanks,

    John

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Warning: array_slice Version 1.4.0’ is closed to new replies.