WARNING: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in
Hello,
After posting the comment, there is an issue requiring allow_url_fopen to be enabled in php.ini. Is it really necessary?
]]>wp_server_stats->check_server_location()
wp_server_stats->dashboard_output()
do_meta_boxes()
wp_dashboard()
file_get_contents()
wp_server_stats->check_server_location()
wp_server_stats->dashboard_output()
do_meta_boxes()
wp_dashboard()
file_get_contents()
wp_server_stats->check_server_location()
wp_server_stats->dashboard_output()
do_meta_boxes()
wp_dashboard()
[12-Feb-2023 20:28:40 UTC] PHP Warning: file_get_contents(): data:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /../wp-content/plugins/mailpoet/lib/NewsletterTemplates/ThumbnailSaver.php on line 126
[12-Feb-2023 20:28:40 UTC] PHP Warning: file_get_contents(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB...
Problem is this code in /lib/NewsletterTemplates/ThumbnailSaver.php
where file_get_contents()
is used with a base 64 encoded data URI.
private function saveBase64AsImageFile(string $file, string $data): bool {
return file_put_contents($file, file_get_contents($data)) !== false;
}
This fails on servers where data://
is disabled via allow_url_fopen
setting in server configuration which seems to be the case in quite many hosting companies.
After seeing several comparable topics, like https://www.ads-software.com/support/topic/uncaught-error-call-to-undefined-function-guzzlehttpchoose_handler/ in this forum, I am posting the following report.
Since the 6.0 update of the Mollie WordPress plugin I am seeing the following PHP errors when visiting the website (hostname replaced with ‘example.com’):
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught RuntimeException: GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler. in /var/www/vhosts/example.com/httpdocs/content/plugins/mollie-payments-for-woocommerce/vendor/guzzlehttp/guzzle/src/functions.php:119\nStack trace:\n#0 /var/www/vhosts/example.com/httpdocs/content/plugins/mollie-payments-for-woocommerce/vendor/guzzlehttp/guzzle/src/HandlerStack.php(42): GuzzleHttp\\choose_handler()\n#1 /var/www/vhosts/example.com/httpdocs/content/plugins/mollie-payments-for-woocommerce/vendor/mollie/mollie-api-php/src/MollieApiClient.php(296): GuzzleHttp\\HandlerStack::create()\n#2 /var/www/vhosts/example.com/httpdocs/content/plugins/mollie-payments-for-woocommerce/src/Mollie/WC/Helper/Api.php(46): Mollie\\Api\\MollieApiClient->__construct()\n#3 /var/www/vhosts/example.com/httpdocs/content/plugins/mollie-payments-for-woocommerce/src/Mollie/WC/Helper/Data.php(341): Mollie_WC_Helper_Api->getApiClient()\n#4 /var/www/v...', referer: https://example.com/
Strange and incorrect, because the cURL functions in PHP are actually enabled. The allow_url_fopen
function is disabled on purpose because of security reasons.
Can we use the Mollie plugin without having to allow insecure PHP settings like allow_url_fopen
?
And furthermore, have you considered looking at built-in WordPress functions for these types of requests, like for example https://developer.www.ads-software.com/reference/functions/wp_remote_request/ ?
Best regards,
–Vincent
I have installed the plugin and when i try to activate the plugin i get the message below.
You need to set PHP directive allow_url_fopen = On. Please contact your web hosting company for help.
I put the allow_url_fopen = On in the php.ini but still get the same message.
Can you help me?
Thank you!
]]>An alternative that works using curl but would be great to have it as standard.
Function:
function url_get_contents ( $url ) {
if ( ! function_exists( 'curl_init' ) ) {
die( 'The cURL library is not installed.' );
}
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
return $output;
}
Usage:
$remote_file_data = url_get_contents( $image_url );
]]>Is “allow_url_fopen” required to be enabled for correct operation of the plugin ?
It doesn’t appear to be listed as a requirement in the FAQ.
The plugin appears to work and doesn’t display any errors on the settings page but I see the following warnings in my logs.
PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/domain.com/wp-content/plugins/webp-converter-for-media/app/Settings/Errors.php on line 82
PHP Warning: file_get_contents(https://domain.com/wp-content/plugins/webp-converter-for-media/public/img/icon-before.png2): failed to open stream: no suitable wrapper could be found in /home/domain.com/wp-content/plugins/webp-converter-for-media/app/Settings/Errors.php on line 82
Thanks.
Best Regards
[24-Feb-2020 19:33:08 UTC] PHP Warning: get_headers(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/USERNAME/public_html/wp-content/plugins/accelerated-mobile-pages/templates/features.php on line 7788
[24-Feb-2020 19:33:08 UTC] PHP Warning: get_headers(): This function may only be used against URLs in /home/USERNAME/public_html/wp-content/plugins/accelerated-mobile-pages/templates/features.php on line 7788
]]>