jaredatch / Shared-Counts

WordPress plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts.
GNU General Public License v2.0
47 stars 16 forks source link

BUG: Cant edit PHP Files in WP Backend with this Plugin enabled (WP 4.9) #120

Closed mhsdesign closed 2 years ago

mhsdesign commented 2 years ago

Plugin version

Shared Counts: 1.3.0 WordPress: 4.9.19

Maybe it will just be resolved by updating WP, but nevertheless i wanted to share this:

Current Behavior

When this plugin is activated and i want to php files in the WP backend, i get this error:

Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.

Expected Behavior

That i can edit php files in the WP Backend editor.

Possible Solution

I seems that on my WP version, this Plugin is interfering with the Wordpress it makes for PHP files. Disabling the Plugin temporary helps.

billerickson commented 2 years ago

Yes, this is a known issue but likely cannot be resolved if you are retrieving share counts.

Querying third party APIs for shared count data and updating the database can be time consuming. To ensure this does not impact the website's load time, we call fastcgi_finish_request() before checking if shared counts need to be updated, which finishes the request to the client.

Unfortunately, this means that WordPress can't check for PHP errors because code continues to run after the request is complete.

I do have a partial solution though. If you're only using Shared Counts for the social share buttons and are not retrieving share data from third party sources, there's no reason for us to call fastcgi_finish_request().

I just committed code that disables this code if the count source is set to 'none', which allows the theme file editor to continue working in that instance. This will be available in the next plugin release.