Forum Replies Created

Viewing 15 replies - 1 through 15 (of 148 total)
  • Thread Starter flynsarmy

    (@flynsarmy)

    It’s for whoever maintains the plugin. There is currently a bug in the plugin. I’ve posted the fix above.

    Thread Starter flynsarmy

    (@flynsarmy)

    I’ve discovered the line
    remove_action('delete_post_metadata', '_rvy_limit_postmeta_update', 10);
    is also required or removing featured images on existing brooadcasts when hitting update on a parent post won’t work.

    Thread Starter flynsarmy

    (@flynsarmy)

    Are cron broadcasts part of the base plugin? If so those users will be affected by the issue as well. If not then your solution should work fine!

    I’d recommend checking for function_exists() and adding the action back on broadcast finish as well just incase some users decide they want to do some post-broadcast modifying of posts in which case they WILL want the usual revisionary behaviour to take place.

    Thread Starter flynsarmy

    (@flynsarmy)

    Is the threewp broadcast base plugin source available on Github? I’ll whip up a pull request for an improvement to your logging that helped me debug this issue.

    Thread Starter flynsarmy

    (@flynsarmy)

    That action hook exists for users updating existing posts on the current blog – not what we’re doing. We probably always want broadcast to sync the featured image across blogs for new and existing posts.

    The correct course of action is probably to create a third party add-on that removes the filter on broadcasting_started then re-add it on broadcasting_finished I think.

    Something like so should work:

    add_action('threewp_broadcast_broadcasting_started', function (\threewp_broadcast\actions\broadcasting_started $action) {
        // This action will stop featured images being attached to broadcasted
        // posts when the broadcast is handled via cron.
        remove_action('update_post_metadata', '_rvy_limit_postmeta_update', 10);
    });
    
    add_action('threewp_broadcast_broadcasting_finished', function (\threewp_broadcast\actions\broadcasting_finished $action) {
        // Add the action back for any post-broadcast code that may run
        add_action('update_post_metadata', '_rvy_limit_postmeta_update', 10, 5);
    });

    We’ve started getting this issue too. It could be related to Cloudflare APO caching the nonce. Our site has had issues with APO never actually clearing its cache despite the service claiming there’s a maximum cache time.

    I noticed when we submit a contact form, we get a 400 BAD REQUEST on the POST URL /wp-admin/admin-ajax.php?action=rest-nonce with a response saying rest_cookie_invalid_nonce. Then a GET request for the same URL is made but the endpoint doesn’t seem to exist because the response is just a 0 (this submit was made when not logged into admin).

    EDIT: I think part of the difficulty in testing this behavior is that when web inspector is open, APO cache is bypassed. I’m not sure how or why this happens but it doesn’t seem to be the case in Firefox so I was able to replicate and debug the issue there.

    • This reply was modified 5 years, 1 month ago by flynsarmy.
    Thread Starter flynsarmy

    (@flynsarmy)

    Works like a charm. Thank you very much.

    Ahh, I had a similar issue and debugged it here:
    https://ww.wp.xz.cn/support/topic/unable-to-trash-pending-revisions

    Looks like in the RC linked they didn’t modify the function I specified.

    • This reply was modified 6 years, 3 months ago by flynsarmy.
    Thread Starter flynsarmy

    (@flynsarmy)

    This works beautifully. Thank you very much!

    Thread Starter flynsarmy

    (@flynsarmy)

    Thanks, got the download. I’ll test this in the morning and give you an update.

    Thread Starter flynsarmy

    (@flynsarmy)

    Sorry for the delay. Your link redirects to https://temp.plainview.se/public which has hehe.txt, hehe2.txt and volume.png

    • This reply was modified 7 years ago by flynsarmy.
    Thread Starter flynsarmy

    (@flynsarmy)

    Not sure how Guzzle Pool’s work specifically, but a similar implementation in W3 Total Cache would be a huge speedup if one could be figured out.

    Thread Starter flynsarmy

    (@flynsarmy)

    No worries, this should be enough for now. Thanks for your help on this and great response time!

    Thread Starter flynsarmy

    (@flynsarmy)

    I kind of got it working with the following code. This will log the entire broadcast process from start to finish into a single DB row – far more efficient than 30+ DB calls at once.

    add_action('save_post', function($post_id) {
        new DebugBroadcast($post_id, get_current_blog_id());
    }, 1);
    
    class DebugBroadcast
    {
        protected $post_id = 0;
        protected $blog_id = 0;
        protected $logs = [];
    
        public function __construct($post_id, $blog_id)
        {
            $this->post_id = $post_id;
            $this->blog_id = $blog_id;
            add_action('threewp_broadcast_broadcasting_finished', [$this, 'broadcasting_finished']);
            add_filter('ThreeWP_Broadcast_debug_text', [$this, 'debug_text']);
        }
    
        public function broadcasting_finished()
        {
            $this->log();
        }
    
        public function debug_text($data)
        {
            $this->logs[] = sprintf( "%s %s: %s", $data->timestamp, $data->class_name, $data->text );
    
            return $data;
        }
    
        protected function log()
        {
            if ( !$this->logs )
                return;
    
            global $wpdb;
    
            $text = implode("\n", $this->logs);
    
            $wpdb->insert('my_logs_table', [
                'post_id' => $this->post_id,
                'blog_id' => $this->blog_id,
                'message' => $text,
            ]);
    
            $this->logs = [];
        }
    }

    Ideally I’d still like my above suggestion implemented though to allow for picking and choosing of what to log rather than just logging everything the way I’m doing here. There’s a lot of useless info that I really don’t need to log.

    Thread Starter flynsarmy

    (@flynsarmy)

    This is a good start however I’m not able to associate the logs with anything. For example I’m logging:

    ThreeWP_Broadcast: Post_Queue: Broadcast complete. Return value: 1
    ThreeWP_Broadcast: Calculator. Time saved for this post: 9 seconds
    ThreeWP_Broadcast: Calculator. Post update only costs 10 %.
    ThreeWP_Broadcast: Calculator. 0 attachments @ 60 seconds = 0 seconds
    etc

    however I don’t have a post ID, a blog ID or any sort of context for the logs.

    Would it be possible for the debug method to take an optional second argument containing context such as the info above, the broadcast_data object or basically anything and everything possible? It’d make life a lot easier when debugging.

Viewing 15 replies - 1 through 15 (of 148 total)