Automattic / Automattic/jetpack

Sharing: make unneeded external HTTP call even when email is not enabled

Open
#16,400 0 comments 0 reactions 0 assignees View on GitHub
[Feature] Sharing [Focus] Performance [Plugin] Jetpack [Pri] Normal Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

#### Steps to reproduce the issue

1. Install Query Monitor plugin
2. Enable share module without email service
3. Go to a post page
4. When the time is very long to load the page like:
![image](https://user-images.githubusercontent.com/3271612/86524742-4e611a80-be4c-11ea-97c3-f786271145d2.png)
5. Hover the area in the image above & there should be something like "HTTP API Calls (1)", click on it
6. You will see the one in the screenshot section below

#### What I expected

No HTTP call should be made on the server side

#### What happened instead

While getting a list of all services, it made a call to akismet by `Jetpack::is_akismet_active`:
https://github.com/Automattic/jetpack/blob/master/modules/sharedaddy/sharing-service.php#L83-L85

if ( apply_filters( 'sharing_services_email', Jetpack::is_akismet_active() ) ) {
$services['email'] = 'Share_Email';
}

**Screenshots**
If applicable, add screenshots to help explain your problem.

The email service is not enabled, but a HTTP call to akismet is still made:

![image](https://user-images.githubusercontent.com/3271612/86524681-99c6f900-be4b-11ea-8ae6-9ae035dc8116.png)

Contributor guide

Open the contributing guide

Research direction

The relevant logic is in modules/sharedaddy/sharing-service.php at lines 83-85, where the sharing services are assembled. Reproduce the issue with Query Monitor while the email service is disabled, then verify that loading a post page makes no HTTP call to Akismet when email sharing is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.