afragen / git-updater

This WP plugin will update GitHub, Bitbucket, GitLab, and Gitea hosted plugins and themes
https://git-updater.com
MIT License
3.2k stars 462 forks source link

PHP errors when running CLI cron #953

Closed BWBama85 closed 3 years ago

BWBama85 commented 3 years ago

Started appearing after the update to 10.0.

PHP Warning:  Undefined array key "github-updater/vendor/freemius/wordpress-sdk" in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/git-updater/vendor/freemius/wordpress-sdk/start.php on line 192
PHP Warning:  Attempt to read property "plugin_path" on null in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/git-updater/vendor/freemius/wordpress-sdk/start.php on line 197
PHP Warning:  Undefined array key "github-updater/vendor/freemius/wordpress-sdk" in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/simple-author-box-premium/freemius/start.php on line 184
PHP Warning:  Attempt to read property "plugin_path" on null in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/simple-author-box-premium/freemius/start.php on line 189
afragen commented 3 years ago

It looks like an odd issue with the Freemius SDK. Can you make sure you're running the latest version of Git Updater.

You might need to flush all your caches too. I don't know why the array key lists the github-updater path.

FWIW, I haven't seen similar errors.

BWBama85 commented 3 years ago

This is a script I run via crontab. I can disable this plugin and run the script and the error goes away.

afragen commented 3 years ago

Can you share the script in a gist?

BWBama85 commented 3 years ago

It happens on any script I run via crontab or via PHP command line.

Here is a small script that triggers it:

<?php

(php_sapi_name() !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('cli only');

require_once('/home/nginx/domains/bamapolitics.com/public/wp-load.php');

$pages = get_pages(array(
    'parent'    =>  '11801'
));

if ( $pages ) {

    foreach ($pages as $page) {

        $page_id = $page->ID;
        $tag_name = get_the_title($page_id);
        $tag_name = strtolower($tag_name);
        $tag_name = str_replace(" ", "-", $tag_name);

        $current_bp_articles_tagged = get_field( 'bp_articles_tagged', $page_id);
        if ( $current_bp_articles_tagged ) {
            $current_bp_articles_tagged_array = json_decode( stripslashes_deep($current_bp_articles_tagged), true );
        } else {
            $current_bp_articles_tagged_array = array();
        }

        $articles_args = array(
            'posts_per_page' => 10,
            'post_status'   => 'publish',
            'no_found_rows'     => true,
            'post_type'  => 'post',
            'tag'            => $tag_name,
            'orderby'   => 'DESC'
        );

        $articles_query = new WP_Query($articles_args);

        if ( $articles_query->have_posts() ) {

            while ( $articles_query->have_posts() ) {
                $articles_query->the_post();

                $bp_articles = get_the_id();
                $bp_articles_array[] = $bp_articles;
            }
            wp_reset_postdata();

            if ( $current_bp_articles_tagged_array !== $bp_articles_array ) {

                // Get the last id since it will be the most recent post
                $article_id = $bp_articles_array[0];

                // Format before sending to database
                $change_text = '<li>' . get_the_title( $page_id ) . ' was mentioned in <a href="' . get_the_permalink( $article_id ) . '">' . get_the_title( $article_id ) . '</a></li>';
                $bp_articles_tagged_json = json_encode( $bp_articles_array );
                $args['ID'] = $page_id;
                $args['meta_input']['bp_articles_tagged'] = $bp_articles_tagged_json;
                // update_field('bp_articles_tagged', $bp_articles_tagged_json, $page_id);
                update_field('votesmart_change_log', $change_text, $page_id);
                wp_update_post($args);
                wpstp_notification_send_email($page_id);
                // dump($args);
                echo 'Not the same' . PHP_EOL;
            } else {
                echo 'Same' . PHP_EOL;
            }
            unset($bp_articles_array);
        }
    }
}
afragen commented 3 years ago

If you run the script directly from the CLI does it err?

afragen commented 3 years ago

Can you tell what specifically is causing the error?

afragen commented 3 years ago

Is it possible this is a cache issue after updating from GitHub Updater 9.x to Git Updater 10.x?

afragen commented 3 years ago

I think I may have fixed this when removing the Freemius start.php from the autoloader.

https://github.com/afragen/git-updater/commit/74b0d600901bf40d9e10fbf4468b04f4244890be

BWBama85 commented 3 years ago

Sorry for the lack of updates but still getting this error after the upgrade. I have not been able to figure out what is causing it, despite digging around the code.

afragen commented 3 years ago

Is it still causing this issue?

BWBama85 commented 3 years ago

Yes. Same lines as before:

[15:01][root@xxx crons]# php updatepeople_meta.php
PHP Warning:  Undefined array key "github-updater/vendor/freemius/wordpress-sdk" in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/git-updater/vendor/freemius/wordpress-sdk/start.php on line 192
PHP Warning:  Attempt to read property "plugin_path" on null in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/git-updater/vendor/freemius/wordpress-sdk/start.php on line 197
PHP Warning:  Undefined array key "github-updater/vendor/freemius/wordpress-sdk" in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/simple-author-box-premium/freemius/start.php on line 184
PHP Warning:  Attempt to read property "plugin_path" on null in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/simple-author-box-premium/freemius/start.php on line 189

Disabling either of the plugins listed in the error log prevents the error. So there is a conflict somewhere, I just haven't been able to find it.

afragen commented 3 years ago

Can you make sure you're using the current version of Git Updater?

Not sure why errors referenced github-updater.

BWBama85 commented 3 years ago

Version 10.4.0 | By Andy Fragen | View details | GitHub

afragen commented 3 years ago

What folders do you have in wp-content/plugins?

I'm trying to figure out why you have github-updater referenced in the error.

BWBama85 commented 3 years ago
[17:05][root@xxx plugins]# ls -lha
total 116K
drwxr-sr-x 28 nginx nginx 4.0K Jul  9 05:07 .
drwxr-sr-x 13 nginx nginx 4.0K Jul 11 17:05 ..
drwxr-xr-x  6 nginx nginx 4.0K Jul  9 05:07 advanced-custom-fields-pro
drwxr-xr-x  8 nginx nginx 4.0K Jul  1 18:13 amp
drwxr-xr-x  6 nginx nginx 4.0K Jan  3  2021 autodescription
drwxr-xr-x  4 nginx nginx 4.0K May 14 00:21 autoptimize
drwxr-xr-x  5 nginx nginx 4.0K Jul  1 18:35 bama-politics-essentials
drwxr-xr-x  4 nginx nginx 4.0K Nov  2  2020 breadcrumb-navxt
drwxr-xr-x  4 nginx nginx 4.0K May 10 22:58 cache-enabler
drwxr-xr-x 10 nginx nginx 4.0K Jun  3 03:46 cloudflare
drwxr-xr-x  7 nginx nginx 4.0K Apr 29 06:58 contact-form-7
drwxr-xr-x  6 nginx nginx 4.0K May 19 06:01 Easy-Table-of-Contents-master
drwxr-xr-x  6 nginx nginx 4.0K Jul  8 00:10 elasticpress
drwxr-xr-x 11 nginx nginx 4.0K Jul  1 23:37 ewww-image-optimizer
drwxr-xr-x  8 nginx nginx 4.0K Jul  5 03:11 git-updater
-rw-r--r--  1 nginx nginx   28 Oct 23  2018 index.php
drwxr-xr-x  4 nginx nginx 4.0K Apr  6 00:25 onesignal-free-web-push-notifications
drwxr-xr-x 18 nginx nginx 4.0K Jul  6 03:49 paid-memberships-pro
drwxr-xr-x  4 nginx nginx 4.0K Feb 12 09:00 pmpro-add-paypal-express
drwxr-xr-x  5 nginx nginx 4.0K Feb 12 01:56 pmpro-advanced-levels-shortcode
drwxr-xr-x  4 nginx nginx 4.0K Feb 12 02:32 pmpro-email-confirmation
drwxr-xr-x  7 nginx nginx 4.0K Feb 12 03:14 pmpro-email-templates
drwxr-xr-x  7 nginx nginx 4.0K Sep 12  2020 simple-author-box-premium
drwxr-xr-x  8 nginx nginx 4.0K Feb  9 11:31 the-seo-framework-extension-manager
drwxr-xr-x 11 nginx nginx 4.0K Apr 29 23:38 updraftplus
drwxr-xr-x  8 nginx nginx 4.0K Jul  1 18:13 wp-migrate-db-pro
drwxr-xr-x  6 nginx nginx 4.0K May 28 00:51 wp-offload-ses
drwxr-xr-x  2 nginx nginx 4.0K Feb 25  2020 wp-sendy-newsletter-generator
drwxr-xr-x  4 nginx nginx 4.0K May  1 07:56 wp-subscribe-to-posts
BWBama85 commented 3 years ago

I am wondering the same.

$fs_newest_sdk = $fs_active_plugins->plugins[ $fs_newest_sdk->sdk_path ];

I have been trying to figure out why that is having an array key of 'github-updater/vendor/freemius/wordpress-sdk'

afragen commented 3 years ago

Maybe it's cached somewhere? Try clearing all the caches you have, including browser cache.

BWBama85 commented 3 years ago

I don't know where it was cached but it seems it was a cached issue. I disabled all plugins and then reenabled them and now can run the script without any errors.

Thanks for the help and for trying to look into this.