10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
618 stars 156 forks source link

Getting an error on workpress post update of "Uncaught Error: Call to undefined function Distributor\InternalConnections\get_site()" #1218

Open dhanashreekere opened 3 months ago

dhanashreekere commented 3 months ago

Describe the bug

On updating few of the posts on Wordpress VIP website it throws an error of "Updating failed. The response is not a valid JSON response.". image

By checking the network tab it is showing that issue is related to distributor plugin. Error shown below:

To fix this issue I have added the code snippet in networkSiteConnection.php on line 749 by commenting line no. 748 ` //$site = get_site( (int) $blog_id );

if(function_exists('get_site'))
{ $sites= get_site( (int) $blog_id ); } elseif(function_exists('wp_get_site')) { $sites= wp_get_site((int) $blog_id); } `

This code snippet has fixed the call which was failing before.

Steps to Reproduce

  1. Updated the post on wordpress. Changed SEO title in yoast plugin for the post and also content.
  2. On update showed error of "Updating failed. The response is not a valid JSON response." image
  3. On checking the post link, updated the content of post but not yoast plugins attributes (SEO title, meta description, keyphrases).

Screenshots, screen recording, code snippet

API Header: image

Error on Wordpress dashboard Distributor --> pull content image

Error response: "Uncaught Error: Call to undefined function Distributor\InternalConnections\get_site()"

Environment information

No response

WordPress information

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct
    ### Tasks
kirtangajjar commented 1 month ago

@dkotter This issue seems to be caused by older version of WordPress(<4.6.0) that does not have get_site() function. Since we only support WP 5.7+, I think this issue can be closed.

dhanashreekere commented 1 month ago

Hello @kirtangajjar, We were already on the wordpress's 6.3 version. Still we are facing this issue for few of our posts.

kirtangajjar commented 2 weeks ago

@dhanashreekere Would it be possible to share the full stack trace of the error? I'm assuming both the sites are on an internal network?

@qasumitbagthariya I tried to reproduce this error, but I was unable to. Can you try to reproduce it on your end? Do the following:

  1. On a MU site, create a post and then distribute it to the other site.
  2. Update post title, post content and yoast title and excerpt.
  3. Check if you can get the "Updating Failed" error as reported in the issue.
qasumitbagthariya commented 2 weeks ago

@kirtangajjar I tried to reproduce but could not replicate the "Updating Failed" error.