Page blanche après mise à jour du plugin CloudFlare pour WordPress // Blank wordpress website after upgrading CloudFlare Plugin
Salut à tous,
Lors de mon dernier upgrade du plugin CloudFlare pour WordPress ca s’est pas super bien passé ….
Je suis passé de la version 1.3.18 à la version 1.3.20, quelle catastrophe …
Je me suis retrouvé avec une page blanche et des erreurs 500 à foison, HTTP comme HTTPS !
Plus rien ne marchait.
Bon ok j’ai commencé par virer le dossier du plugin par ssh.
Ouais c’est mieux, mon site remarche mais du coup je ne sais pas ce qui déconne …
Allez j’épluche les logs :
access
1.2.3.4 - - [16/Feb/2016:19:48:31 +0100] "GET / HTTP/1.1" 500 5 "http://www.relentlessrevolutions.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:44.0) Gecko/20100101 Firefox/44.0"
1.2.3.4 - - [16/Feb/2016:19:48:34 +0100] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:44.0) Gecko/20100101 Firefox/44.0"
1.2.3.4 - - [16/Feb/2016:19:48:38 +0100] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:44.0) Gecko/20100101 Firefox/44.0"
1.2.3.4 - - [16/Feb/2016:19:49:05 +0100] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36"
Des erreurs 500 partout ca pue…
error
2016/02/16 19:48:34 [error] 2940#0: *3014 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare cloudflare_ssl_srcset() (previously declared in /doss/patate/wp-content/plugins/cloudflare/cloudflare.php:576) in /doss/patate/wp-content/themes/hueman/functions.php on line 839" while reading response header from upstream, client: 173.245.49.143, server: relentlessrevolutions.com, request: "GET /wp-admin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.relentlessrevolutions.com"
2016/02/16 19:48:38 [error] 2940#0: *3012 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare cloudflare_ssl_srcset() (previously declared in /doss/patate/wp-content/plugins/cloudflare/cloudflare.php:576) in /doss/patate/wp-content/themes/hueman/functions.php on line 839" while reading response header from upstream, client: 173.245.49.143, server: relentlessrevolutions.com, request: "GET /wp-admin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.relentlessrevolutions.com"
2016/02/16 19:49:05 [error] 2940#0: *3017 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare cloudflare_ssl_srcset() (previously declared in /doss/patate/wp-content/plugins/cloudflare/cloudflare.php:576) in /doss/patate/wp-content/themes/hueman/functions.php on line 839" while reading response header from upstream, client: 173.245.49.143, server: relentlessrevolutions.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.relentlessrevolutions.com"
Ok ok, qu’est ce qu’on a la alors. (bon je suis nul en programmation ou en code donc désolé si le vocabulaire est incorrect…)
FastCGI essaie de re déclarer la variable cloudflare_ssl_srcset() du fichier /doss/patate/wp-content/plugins/cloudflare/cloudflare.php alors qu’elle l’a déjà été avec /doss/patate/wp-content/themes/hueman/functions.php.
Regardons ces fichiers :
/doss/patate/wp-content/plugins/cloudflare/cloudflare.php
// wordpress 4.4 srcset ssl fix
// Shoutout to @bhubbard: https://wordpress.org/support/topic/44-https-rewritte-aint-working-with-images?replies=12
function cloudflare_ssl_srcset( $sources ) {
$cloudflare_protocol_rewrite = load_protocol_rewrite();
if ($cloudflare_protocol_rewrite == 1) {
foreach ( $sources as &$source ) {
$re = "/https?:\\/\\//i";
$subst = "//";
$return = preg_replace($re, $subst, $source['url']);
if ($return) {
$source['url'] = $return;
}
}
return $sources;
}
return $sources;
}
add_filter( 'wp_calculate_image_srcset', 'cloudflare_ssl_srcset' );
/doss/patate/wp-content/themes/hueman/functions.php
/* WP-PageNavi support - @devinsays (via GitHub)
/* ------------------------------------ */
function alx_deregister_styles() {
wp_deregister_style( 'wp-pagenavi' );
}
add_action( 'wp_print_styles', 'alx_deregister_styles', 100 );
function cloudflare_ssl_srcset( $sources ) {
$cloudflare_protocol_rewrite = load_protocol_rewrite();
if ($cloudflare_protocol_rewrite == 1) {
foreach ( $sources as &$source ) { $source['url'] = set_url_scheme( $source['url'] );
}
return $sources;
} else {
foreach ( $sources as &$source ) { $sources;
}
return $sources;
} }
add_filter( 'wp_calculate_image_srcset', 'cloudflare_ssl_srcset' );
Ca alors ca se ressemble.
Bon ben je vais privilégier le code du plugin vu qu’il est plus récent que celui de mon thème.
Allez hop zou, je commente la partie de mon thème.
Je rafraichis ma page … et magie !! Hourra ! Vive le roi ! Ca marche ! :)
TLDR : Regardez vos logs et regardez si c’est le même problème que moi ! Si oui faite du ménage !
Commentaires récents