Closed skyzer closed 11 months ago
Hint: Issue is in admin/class-itella-shipping-method.php
file on update_locations()
function that pulls the huge JSON file new PickupPoints('https://delivery.plugins.itella.com/api/locations');
and for some reason filesystem cache approach does not work nor even added wordpress's built in transient DB cache layer.
Upon further digging the API method returns only location of 4 countries: EE, LV, LT, FI.
But the foreach loop in update_locations
has all EU countries, so it loops through all of them. So this piece of code
if ($update_file) {
$itella_pickup_points_obj = new PickupPoints('https://delivery.plugins.itella.com/api/locations');
$locations = $itella_pickup_points_obj->getLocationsByCountry($country_code);
if (!empty($locations)) {
// Save to a file
file_put_contents($filename, json_encode($locations));
}
} else {
// Load from the file if the transient is not available but the file is up-to-date
}
is going to update the file so it goes and does API request with getLocationsByCountry
. As I've said above API returns only 4 countries (EE, LV, LT, FI) and does not return any other country. Because the country was not found in API request, it does not go into !empty($locations)
condition, therefore it does not save that location into a file, because there is nothing to save. Because of that every other EU country is receiving API call on every request :)
Hello,
Thank you for reporting the issue you noticed. The fix you suggested didn't acceptable for us, but we built a fix based on it in PR #91.
Without this plugin activated loads 0.5 seconds, everything loads at least 10 seconds when I'm logged in. Using Query Monitor to track it. See Query Monitor output. Nothing visibly eyecatching that cause problems.
Plugin deactivated:
With plugin activated
I am getting some PHP warnings on deprecated issues
Environment (PHP 8.2.12):