REST API, Loopback issues – plus PLugin looks abandoned

Home Forums Main plugin support REST API, Loopback issues – plus PLugin looks abandoned

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #662591
    mrlennyman
    Participant

    Hi there,

    I am using the plugin on a site which is reporting 2 issues.

    1. When I review the Health status of the site, I get the issues below – I worked through this with the hosting support and isolated your plugin as the cause of the issue – when your plugin is disabled the issues go away.

    Can you advise on what best to do? We are using version 7.8.

    THE REST API ENCOUNTERED AN ERROR
    The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

    The REST API request failed due to an error.
    Error: [] cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

    YOUR SITE COULD NOT PERFORM A LOOPBACK REQUEST
    Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.

    The loopback request to your site failed, this means features relying on them are not currently working as expected.
    Error: [] cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

    2. When scanning the site with Wordfence, it reports that “addintional Owner Types” appears to be abandoned.
    Can you please advise on best practice to fix this?

    Plugin URL: https://wp-customerarea.com/downloads/wpca-additional-owner-types/

    Details: It was last updated 2 years 8 months ago and tested up to WordPress 5.2.2. Plugins can be removed from wordpress.org for various reasons. This can include benign issues like a plugin author discontinuing development or moving the plugin distribution to their own site, but some might also be due to security issues. In any case, future updates may or may not be available, so it is worth investigating the cause and deciding whether to temporarily or permanently replace or remove the plugin. Get more information.

    Many thanks!

    #665067
    Thomas Lartaud
    Keymaster

    Hi,

    1. I have an idea that might probably work… Could you try this, please?
    Open the file customer-area/src/php/core-classes/addon.class.php, line 289, replace this:

    public function do_periodical_license_check()
            {
                // Don't fire when saving settings
                if ( !empty($_POST['cuar_do_save_settings'])) return;
    
                // Bail if doing ajax
                if (defined('DOING_AJAX') && DOING_AJAX) return;

    with this:

    public function do_periodical_license_check()
            {
                // Don't fire when saving settings
                if ( !empty($_POST['cuar_do_save_settings'])) return;
    
                // Bail if doing ajax
                if (defined('DOING_AJAX') && DOING_AJAX) return;
    
                // Bail if doing rest
                if (defined('REST_REQUEST') && REST_REQUEST) return;

    Then run site health check again to see if it helps.

    2. No worries, this plugin is not abandoned. We did not need to update it for a period, that’s probably why Wordfence wrongly claims that the plugin is abandoned.
    Plus, Wordfence is not supposed to know that this is an add-on, not a standalone plugin. Our add-ons updates are sometimes bundled into the main plugin core, to avoid code duplicates in all others add-ons.
    You should probably ask Wordfence a way to disable this warning. I don’t know how this is working, sry.

    Regards.

    #665228
    Thomas Lartaud
    Keymaster

    Ok,

    I think I may have found the issue. Try this please:

    Open the file customer-area/src/php/core-classes/plugin.class.php, line 357, replace

    if ( !session_id()) session_start();

    with

    if ( !session_id()) session_start(['read_and_close' => true]);

    Let me know if that worked for you, and I’ll release an update as soon as possible.

    Regards.

    #665906
    Thomas Lartaud
    Keymaster

    Hi,

    I made a few searches, and I found out that it is a known WP bug, causing site health checks to timeout when there are some active plugins using PHP sessions.

    The following code can fix your issue. Or you can wait for an incoming release from WP that should fix it.

    /**
     * Write session to disk to prevent cURL time-out which may occur with
     * WordPress (since 4.9.2, see https://core.trac.wordpress.org/ticket/43358),
     * or plugins such as "Health Check".
     */
    function custom_wp_fix_pre_http_request($preempt, $r, $url)
    {
        // CUSTOM_WP_FIX_DISABLE_SWC can be defined in wp-config.php (undocumented):
        if ( !defined('CUSTOM_WP_FIX_DISABLE_SWC ') && isset($_SESSION)) {
            if (function_exists('get_site_url')) {
                $parse = parse_url(get_site_url());
                $s_url = @$parse['scheme'] . "://{$parse['host']}";
                if (strpos($url, $s_url) === 0) {
                    @session_write_close();
                }
            }
        }
    
        return false;
    }
    add_filter('pre_http_request', 'custom_wp_fix_pre_http_request', 10, 3);

    Regards.

    #680045
    mrlennyman
    Participant

    Hi there,

    Sorry only coming back to this now and nevcer got email notifications.

    I have updated to wordpress 5.4 but the issue persists.
    Where do I add this last code snippet to help fix the issue?

    Thank you for your time.

    #680046
    mrlennyman
    Participant

    Sorry – quick update – I applied this code and the eror has been fixed.
    THANK YOU!!!

    Ok,

    I think I may have found the issue. Try this please:

    Open the file customer-area/src/php/core-classes/plugin.class.php, line 357, replace
    1

    if ( !session_id()) session_start();

    with
    1

    if ( !session_id()) session_start([‘read_and_close’ => true]);

    Let me know if that worked for you, and I’ll release an update as soon as possible.

    Regards.

    #680245
    Thomas Lartaud
    Keymaster

    Yes, but this is not the correct final fix.

    We have to wait for a WP fix.
    Use the code given above until its fixed in WP core.

    Add it in a custom wp plugin.

    Regards.

    #736626
    ac1957
    Participant

    I made a plugin using the above code and it seems to work on one of my sites where curl was timing out. However, it did not work on the other site which is a cURL error 60. Any suggestions on how to fix that would be greatly appreciated.

    Also, will WP Customer Area work with woo-commerce products?

    #736935
    Thomas Lartaud
    Keymaster

    Hi @ac1957,

    I’m sorry but I have no idea. This is a WordPress issue.
    WP Site Health should normally not warn about this issue since WPCA 7.9.0

    However, some other plugins might still block CURL requests checks. You can maybe look for a plugin conflict. Eg. disable plugins on by one until the issue disappear.

    Regards.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.