Thanks for reporting π
The error is a symptom of a PHP error. Can you check the debug log? (wp-content/debug.log). If there is no log, you must first enable debugging
Debugging in WordPress
Thread Starter
Davide
(@imperatodavide)
This happens when you try to find an hard solution and the log did the trick! I’ve found an error due to another active plugin. Thanks for the suggestion and for your plugin! π
After updating to version 0.18.1 I’ve got the same errors when calling the “WebP Express settings” page:
document.getElementById("converters") returns null. Strange! Please report.
document.getElementById("whitelist") returns null. Strange! Please report.
In my case the content of the “debug.log” file gives NO hint, that an error of another plugin is involved.
Content of debug.log
[27-Sep-2020 13:00:58 UTC] PHP Fatal error: Uncaught Error: Call to a member function getAll() on array in /var/www/vhosts/test.my-domain.com/httpdocs/portal/wp-content/plugins/webp-express/lib/classes/
WPHttpRequester.php:24
Stack trace:
#0 /var/www/vhosts/test.my-domain.com/httpdocs/portal/wp-content/plugins/webp-express/vendor/rosell-dk/htaccess-capability-tester/src/Testers/AbstractTester.php(130): WebPExpress\WPHttpRequester->makeHTT
PRequest()
#1 /var/www/vhosts/test.my-domain.com/httpdocs/portal/wp-content/plugins/webp-express/vendor/rosell-dk/htaccess-capability-tester/src/Testers/CustomTester.php(155): HtaccessCapabilityTester\Testers\Abstr
actTester->makeHttpRequest()
#2 /var/www/vhosts/test.my-domain.com/httpdocs/portal/wp-content/plugins/webp-express/vendor/rosell-dk/htaccess-capability-tester/src/Testers/CustomTester.php(197): HtaccessCapabilityTester\Testers\Custo
mTester->realRunSubTest()
#3 /var/www/vhosts/test.my-domain.com/httpdocs/portal/wp-content/plugins/webp-express/vendor/rosell-dk/htaccess-capability-tester/src/Testers/CustomTester.php(220): Htacc in /var/www/vhosts/demo.hometix.
eu/httpdocs/portal/wp-content/plugins/webp-express/lib/classes/WPHttpRequester.php on line 24
Any help would be appreciated.
Thanks for the debug log!
I can fix this
I believe that this will fix it:
1. Edit wp-content/plugins/webp-express/lib/classes/WPHttpRequester.php
2. Replace the entire content of the file with this:
<?php
namespace WebPExpress;
use \HtaccessCapabilityTester\HttpRequesterInterface;
use \HtaccessCapabilityTester\HttpResponse;
class WPHttpRequester implements HttpRequesterInterface
{
/**
* Make a HTTP request to a URL.
*
* @param string $url The URL to make the HTTP request to
*
* @return HttpResponse A HttpResponse object, which simply contains body, status code
* and response headers
*/
public function makeHTTPRequest($url) {
$response = wp_remote_get($url, ['timeout' => 10]);
//echo '<pre>' . print_r($response, true) . '</pre>';
if (is_wp_error($response)) {
return new HttpResponse('0','',[]);
} else {
$body = wp_remote_retrieve_body($response);
$statusCode = wp_remote_retrieve_response_code($response);
$headersDict = wp_remote_retrieve_headers($response);
if (method_exists($headersDict, 'getAll')) {
$headersMap = $headersDict->getAll();
} else {
$headersMap = [];
}
return new HttpResponse($body, $statusCode, $headersMap);
}
}
}
It would be great if you can confirm that this fixes it before I release the bugfix. On the other hand, I would like to release it as quickly as possible, so reply now, if you have the chance to test out the fix
I just released 0.18.2, which should fix this issue. Can you confirm that it fixes the issue?
Sorry, for the late response. I had a lot of work.
After I installed the Version 0.18.2 this messages were presented, when I called the “WebP Express Settings” page.
It seems your server setup does not support headers in .htaccess. You should either fix this (install mod_headers) or deactivate the “Enable direct redirection to existing converted images?” option. Otherwise the Vary:Accept header will not be added and this can result in problems for users behind proxy servers (ie used in larger companies)
The “mod_headers” Apache module is installed since a long time. Therefore I don’t understand why this message is presented.
You have turned on “Enable redirection to converter” and “Create webp files upon request?””. However, these features does not work on your current server settings / wordpress setup, because the PHP scripts in the plugin folder (in the “wod” and “wod2” subfolders) fails to run when requested directly. You can try to fix the problem or simply turn them off and rely on “Convert on upload” and “Bulk Convert” to get the images converted.
If you are going to try to solve the problem, you need at least one of the following pages to display “pong”: wod-test or wod2-test. The problem will typically be found in the server configuration or a security plugin. If one of the links results in a 403 Permission denied, look out for “deny” and “denied” in httpd.conf, /etc/apache/sites-enabled/your-site.conf and in parent .htaccess files.
Both “ping.php” pages (“wod-test” and “wod2-test”) showing the word “pong”. I see no reason, why this message is presented.
I think I have to do some further tests to check if everything works as usual without changing my settings. I’ll come back to you with the results.
On my server Apache and Nginx (as proxy) run under the server management software “Plesk Obsidian 18.0.29”.
In order to be able to successfully complete all three live tests in ALL points in the WebP Express Settings (via the “Live Test” buttons), I had to make various tweaks for Apache and the Nginx in Plesk Obisian.
Apache – I’ve added this code
# https://stackoverflow.com/questions/60997198/why-nginx-does-not-forward-vary-header-sent-by-apache-in-proxy-mode
<IfModule mod_setenvif.c>
SetEnvIf Request_URI "\.(jpe?g|png|webp)$" REQUEST_image
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REQUEST_image
</IfModule>
Nginx Configuration in Plesk Obsidian
– “Proxy mode” is turned on
– “Smart static files processing” is turned on
– “Serve static files directly by nginx” is turned on and added “webp” as file type to the file type list
Nginx – added to conf
gzip on;
gzip_vary on;
Since all three live tests give an OK on all points, I am surprised that the messages about the missing VARY HEADER described in my previous post are still displayed. Nevertheless, everything seems to work as it should and all Live-Test give an OK in alle point.
But maybe that will help someone solve the same problem.