Site crash with PHP 8
-
Hello,
I using code snippets more than 2 years and Im very happy.
Last week I tried to update to PHP 8, but with both versions the wordpress site crash with activating code snippets.Can someone help me what has fundamentally changed? should I post the current PHP snippet once?
-
I’d like yo see the error you get. And the snippet would be cool too.
The plugin has been developed on and tested with PHP 8, so it’s likely this is an issue with one of your snippets. If you’re able to track down which one is causing the issue and post here, we might be able to help you fix it up.
My php snippet:
add_action( 'woocommerce_share', 'bbloomer_custom_action', 5 ); function bbloomer_custom_action() { echo '<div class="atkp-disclaimer2">* Wir weisen darauf hin, dass sich hier angezeigte Preise inzwischen ge?ndert haben k?nnen. Alle Angaben ohne Gew?hr. <br> Wenn du über den Button "Produkt kaufen" ein Produkt bestellst, bekommen wir dafür eine Provision vom Verk?ufer. Für dich entstehen selbstverst?ndlich keine zus?tzlichen Kosten.</div>'; } function no_self_ping( &$links ) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action( 'pre_ping', 'no_self_ping' ); function search_form_shortcode( ) { get_search_form( ); } add_shortcode('search_form', 'search_form_shortcode'); function comment_after_policy_field() { echo '<br><p>Hast du Probleme bei der Einrichtung oder Fragen zu technischen Produkten? Dann kannst du gerne deine Frage in unserer <b><a href="https://www.facebook.com/groups/internetderdinge">Facebook Gruppe</a></b> stellen. Die IDD-Community wird versuchen dein Anliegen zu l?sen.</p>'; } add_action('comment_form', 'comment_after_policy_field'); add_action('admin_head', 'pfc_tinymce_custom_vars'); function disable_comment_url($fields) { unset($fields['url']); return $fields; } add_filter('comment_form_default_fields','disable_comment_url'); /** * Open all external links in a new window */ // This will take care of the Buy Product button below the external product on the Shop page. add_filter( 'woocommerce_loop_add_to_cart_link', 'ts_external_add_product_link' , 10, 2 ); // Remove the default WooCommerce external product Buy Product button on the individual Product page. remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); // Add the open in a new browser tab WooCommerce external product Buy Product button. add_action( 'woocommerce_external_add_to_cart', 'ts_external_add_to_cart', 30 ); function ts_external_add_product_link( $link ) { global $product; if ( $product->is_type( 'external' ) ) { $link = sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s" target="_blank">%s</a>', esc_url( $product->add_to_cart_url() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( isset( $class ) ? $class : 'button product_type_external' ), esc_html( $product->add_to_cart_text() ) ); } return $link; } function ts_external_add_to_cart() { global $product; if ( ! $product->add_to_cart_url() ) { return; } $product_url = $product->add_to_cart_url(); $button_text = $product->single_add_to_cart_text(); /** * The code below outputs the edited button with target="_blank" added to the html markup. */ do_action( 'woocommerce_before_add_to_cart_button' ); ?> <p class="cart"> <a href="<?php echo esc_url( $product_url ); ?>" rel="nofollow" class="single_add_to_cart_button button alt" target="_blank"> <?php echo esc_html($button_text ); ?></a> </p> <?php do_action( 'woocommerce_after_add_to_cart_button' ); } /** * Changes the external product button's add to cart text * * @param string $button_text the button's text * @param \WC_Product $product * @return string - updated button text */ //function sv_wc_external_product_button( $button_text, $product ) { // // if ( 'external' === $product->get_type() ) { // enter the default text for external products // return $product->button_text ? $product->button_text : 'Jetzt kaufen'; // } // return $button_text; //} //add_filter( 'woocommerce_product_single_add_to_cart_text', 'sv_wc_external_product_button', 10, 2 ); function sv_wc_external_product_button( $button_text ) { return 'Jetzt kaufen'; } add_filter( 'woocommerce_product_single_add_to_cart_text', 'sv_wc_external_product_button' ); /** * Disable WooCommerce block styles (front-end). */ function slug_disable_woocommerce_block_styles() { wp_dequeue_style( 'wc-block-style' ); } add_action( 'wp_enqueue_scripts', 'slug_disable_woocommerce_block_styles' ); /** * Geschwindigkeit verbessern */ add_filter ('wpcf7_load_js', '__return_false'); add_filter ('wpcf7_load_css', '__return_false'); remove_action ('wp_head', 'wlwmanifest_link'); remove_action ('wp_head', 'wp_generator'); add_filter ('xmlrpc_enabled', '__return_false'); remove_action ('wp_head', 'print_emoji_detection_script', 7); remove_action ('wp_print_styles', 'print_emoji_styles'); remove_action ('admin_print_scripts', 'print_emoji_detection_script'); remove_action ('admin_print_styles', 'print_emoji_styles'); remove_action ('wp_head', 'rsd_link'); /** Disable Ajax Call from WooCommerce on front page and posts*/ add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11); function dequeue_woocommerce_cart_fragments() { if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments'); } //Remove JQuery migrate function remove_jquery_migrate($scripts) { if (!is_admin() && isset($scripts->registered['jquery'])) { $script = $scripts->registered['jquery']; if ($script->deps) { // Check whether the script has any dependencies $script->deps = array_diff($script->deps, array( 'jquery-migrate' )); } } } add_action('wp_default_scripts', 'remove_jquery_migrate'); /* Kryptow?hrungen Kategorie aus Startseite ausschlie?en */ function theme_slug_exclude_categories( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-6546' ); } } add_action( 'pre_get_posts', 'theme_slug_exclude_categories' ); // WooCommerce Shop-Seite auf 4 Spalten einstellen add_filter( 'loop_shop_columns', 'az_product_columns', 5); function az_product_columns($columns) { if ( is_shop() || is_product_category() || is_product_tag() ) { $columns = 4; return $columns; } }
There is only crashing the backend site with php8 and enabled code snippets. With 7.4 everything working good
On the backend I got this:
?Es gab einen kritischen Fehler auf deiner Website“
“There was a critical error on your website”A quick heads-up regarding WP and PHP 8.0:
This is official WP information directly from the Make WordPress Core blog.
And this is just WordPress – there are still tons of plugins in the repo (and elsewhere) that don’t or can’t work 100% either due to the incomplete WP support for this PHP version or to the state of “PHP8-readiness” of their own code.
I would recommend to each site owner not to upgrade to PHP 8 as long as WP doesn’t offer full support.
Just my two cents. ??
- This reply was modified 2 years, 9 months ago by Gabor Lippert.
- This reply was modified 2 years, 9 months ago by Gabor Lippert.
But the next sentence is “All remaining known PHP 8.1 issues are deprecation notices.”
So as I understand WordPress should not give any error with PHP 8.0/1 ???♂?
ˉ\\_(ツ)_/ˉ – Not sure about this.
I’m a developer, and this reported issue is about the 3rd PHP8-support related bug report in one month. And there’s always some relation to the $wpdb class.
- This reply was modified 2 years, 9 months ago by Gabor Lippert.
- The topic ‘Site crash with PHP 8’ is closed to new replies.