Skip to main content

PHP 8 deprecates in Wordpress: class-wp-list-table.php:717



There has been released latest versions PHP 8.0 and 8.1 but Wordpress and some of its plugins are not ready to convey the patterns provided in PHP 8. I just found today that after upgrading a website from 7.4, a lot of error notifications appeared everywhere in the website when enabling of debug mode. However, we will focused on the given title in this blog as important matter in order to check the status of the orders if approved, pending or cancelled.

This content lets you spend very short time in finding out errors in Wordpress 6.0 with PHP 8.0 most specifically the one I had figured out from this notice "Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /www/.../wp-admin/includes/class-wp-list-table.php:717". However, in our case, the website has an installed plugins "Advanced Custom Field Pro" and "Woocommerce 7.3" which combined to manipulate order statuses. The website has an e-commerce platform that visitors can shop online.

I tried to look at the line 717, as shown code below:

707: /**
708: * Filters the 'Months' drop-down results.
709: *
710: * @since 3.7.0
711: *
712: * @param object[] $months    Array of the months drop-down query results.
713: * @param string   $post_type The post type.
714: */
715: $months = apply_filters( 'months_dropdown_results', $months, $post_type );
716: 
717: $month_count = count( $months );
718: 
719: if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
720:  return;
721: }

Yet, I realized that the code on line 717 explicitly counts results of order status in array and that was deprecated in PHP 8. Maybe to organize the declarations for checking then execute supplied code. I had to touch the WP core file and implement checking method if variable $months which is in array have bulking values then I replaced with the organized one with following:

717: $month_count = $months ? count( $months ) : 0;

Variable $month_count first check values of $month whether it has a value or zero value that thrown to the following condition statement below it that either it is true or false, it will return to checking method and execute.

When you have a problem with multiple errors in Wordpress under PHP 8, I am willing to solve it and give the solution. Just comment down.

Comments

Popular posts from this blog

Working Dark Web links in 2021

.Onion v2 will be deprecated in October 2021. v3 .onion sites will be formally launched. Yet, if you are wondering what's all about .onion, download Tor Browser and install to your computer. Tor will connects you to the deep web often called "hidden sites" and some calls it "dark web". Note: Never open the links if you do not have information about .onion sites.  FAQ What are .onion links?   onion links are only accessible via the Tor Network, commonly known as the "dark web"   How do I access .onion links?   you need the Tor Browser, which is a modified version of Firefox that routes any traffic through the Tor Network   Is accessing the Tor Network/Dark Web illegal?   a quick search in your prefered search engine will give you the answer  How do I stay safe while browsing the dark web?   only use the Tor Browser on a Unix based OS (macOS/OSX and Linux (any distro/flavor will do)) and have a VPN that does not ...

Best guidelines for designing a modern projects with embedded systems

Engineers, physicists, and programmers share a common thread in their dedication to the realms of calculations, computations and risk analysis. This post offers insights that can greatly enhance your creativity and proficiency. I am presenting a condensed approach to designing a contemporary system utilizing embedded systems electronics. Here, you can adhere to the instructions outlined in the list. Fundamental guidelines for crafting a unique DAC-ADC System in automation and IoT projects: 1. Creative Ideation: Commence with innovative ideation, fostering a distinct vision for the DAC-ADC system’s unique attributes and functionalities. 2. Strategic Market Planning: Undertake comprehensive market planning, encompassing market research, competitive analysis, and identification of market demands. 3. Research Study Compilation: Develop a meticulously researched study, delineating technical prerequisites, market dynamics, and potential applications. 4. Systematic Data Acquisition: Execute a...

LET Grading System: Elementary and Secondary Levels Explained with Examples

The Licensure Examination for Teachers (LET) is an important examination that aspiring teachers must take in order to obtain their teaching license in the Philippines. In this tutorial, we will explore the grading system for the LET, specifically for the Elementary Level and Secondary Level where "x" is the candidate's average each category such as general education and professional education. Elementary Level: General Education: 60% * x  Professional Education: 40% * x Example: If a candidate scores 80 in General Education and 90 in Professional Education, the calculation would be as follows: General Education score = 80 * 0.6 = 48 Professional Education score = 90 * 0.4 = 36 Final Score = 48 + 36 = 84 Secondary Level: General Education: 20% * x  Professional Education: 40% * x  Major: 40% * x  Example: If a candidate scores 75 in General Education, 85 in Professional Education, and 80 in Major, the calculation would be as follows: General Education score = 75 * 0.2...