Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4 #10

Open
bobbingwide opened this issue Dec 4, 2023 · 3 comments
Open

Support PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4 #10

bobbingwide opened this issue Dec 4, 2023 · 3 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

Update code to run without problems in PHP 8.1, PHP 8.2, and PHP 8.3 with WordPress 6.4.1

See bobbingwide/bobbingwide#103 and bobbingwide/bobbingwide#114

@bobbingwide bobbingwide self-assigned this Dec 4, 2023
@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 25, 2024

Getting the following messages in oik-plugins.co.uk and oik-plugins.com

[24-Nov-2024 21:23:20 UTC] PHP Warning:  Attempt to read property "count" on array in /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php on line 131
[24-Nov-2024 21:23:20 UTC] PHP Warning:  Attempt to read property "name" on array in /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php on line 137
[24-Nov-2024 21:23:20 UTC] PHP Warning:  Attempt to read property "term_id" on array in /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php on line 59

I reproduced the problem in oik-plugins.co.uk,
for https://www.oik-plugins.co.uk/?post_type=oik_class,
but not in s.b/oikcom.
Interestingly in both s.b/oikcom and oik-plugins.co.uk the letter navigation isn't visible for oik_class

The backtrace is

/home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-bwtrace/includes/bwtrace-actions.php(287:2) bw_trace_error_handler(1) 225 1 2024-11-25T16:22:02+00:00 0.362549 0.000401 cf=genesis_before_loop,oik_a2z_display 30358 72 37075 98566144/100847616 768M F=1700 err Array

    [0] => (integer) 2
    [1] => (string) "Warning: Attempt to read property "count" on array"
    [2] => (string) "/home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php"
    [3] => (integer) 131

0. bw_lazy_backtrace /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-bwtrace/libs/bwtrace.php:108 0
1. bw_backtrace /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-bwtrace/includes/bwtrace-actions.php:294 0
2. bw_trace_error_handler(2,Attempt to read property "count" on array,/home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php,131) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php:131 4
3. display_term_item(array) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php:103 1
4. display_term_list(object) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php:32 1
5. display(oik_letters,array) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/oik-a2z.php:76 2
6. oik_a2z_display(oik_letters,array) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/class-wp-hook.php:324 2
7. apply_filters(,array) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/class-wp-hook.php:348 2
8. do_action(array) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/plugin.php:517 1
9. do_action(oik_a2z_display,oik_letters,array) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/themes/genesis-oik/functions.php:296 3
10. genesis_oik_a2z() /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/class-wp-hook.php:324 1
11. apply_filters(,array) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/class-wp-hook.php:348 2
12. do_action(array) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/plugin.php:517 1
13. do_action(genesis_before_loop) /home/customer/www/oik-plugins.co.uk/public_html/wp-content/themes/genesis/lib/framework.php:59 1
14. genesis /home/customer/www/oik-plugins.co.uk/public_html/wp-content/themes/genesis-oik/archive.php:83 0
15. include(/home/customer/www/oik-plugins.co.uk/public_html/wp-content/themes/genesis-oik/archive.php) /home/customer/www/oik-plugins.co.uk/public_html/wp-includes/template-loader.php:106 1
16. require_once(/home/customer/www/oik-plugins.co.uk/public_html/wp-includes/template-loader.php) /home/customer/www/oik-plugins.co.uk/public_html/wp-blog-header.php:19 1
17. require(/home/customer/www/oik-plugins.co.uk/public_html/wp-blog-header.php) /home/customer/www/oik-plugins.co.uk/public_html/index.php:17 1
/home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/oik-a2z/includes/class-oik-a2z-display.php(136:0) OIK_a2z_display::display_term_item(1) 226 1 2024-11-25T16:22:02+00:00 0.363724 0.001175 cf=genesis_before_loop,oik_a2z_display 30358 72 37075 98566144/100847616 768M F=1700 term empty? Array

    [invalid_taxonomy] => Array

        [0] => (string) "Invalid taxonomy."

@bobbingwide
Copy link
Owner Author

I was able to reproduce the problem in s.b/oikcom by deactivating the oik-shortcodes-a2z plugin so that the oik_letters taxonomy isn't attached to oik_class.

The problem occurs when the URL is /oikcom/oik_letters/f/?post_type=oik_class
which is where you end up after attempting to visit
/oikcom/?post_type=oik_class.

No, I don't understand it yet.

Anyway, the genesis_oik theme calls genesis_oik_a2z_letters() in response to genesis_before_loop
in the taxonomy-oik_letters.php template.

function genesis_oik_a2z_letters() {
	$args = genesis_oik_a2z_display_args();
	$taxonomy = genesis_oik_a2z_query_letter_taxonomy( "oik_letters", $args );
	do_action( "oik_a2z_display", $taxonomy, $args );
}

The default taxonomy passed is oik_letters.
The code in genesis_oik_a2z_query_letter_taxonomy() assumes the taxonomy is attached so it returns this value which is then passed on the action hook oik_a2z_display.
oik-a2z calls get_terms() which returns a WP_Error when the taxonomy doesn't exist.
The code isn't handling this error correctly, treating it as an array of terms.
Hence the messages.

@bobbingwide bobbingwide changed the title Support PHP 8.1, PHP 8.2 and PHP 8.3 Support PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4 Nov 25, 2024
@bobbingwide
Copy link
Owner Author

No, I don't understand it yet.

So now I have to try to understand why the request seemed to change.
I ran the test again and got a response that made more sense.

C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php(288:2) bw_trace_error_handler(6) 189 7 2024-11-25T18:45:17+00:00 2.391184 0.000142 cf=genesis_before_loop,oik_a2z_display 27049 38 48707 88080384/92274688 512M F=1791 en_US err Array

[0] => (integer) 2
[1] => (string) "Warning: Attempt to read property "term_id" on array"
[2] => (string) "C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php"
[3] => (integer) 60
  1. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\libs\bwtrace.php:108 0
  2. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:295 0
  3. bw_trace_error_handler(2,Attempt to read property "term_id" on array,C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php,60) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php:60 4
  4. query_active_term(array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php:73 1
  5. query_term_class(array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php:140 1
  6. display_term_item(array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php:104 1
  7. display_term_list(object) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php:32 1
  8. display(oik_letters,array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\oik-a2z.php:76 2
  9. oik_a2z_display(oik_letters,array) C:\apache\htdocs\oikcom\wp-includes\class-wp-hook.php:324 2
  10. apply_filters(,array) C:\apache\htdocs\oikcom\wp-includes\class-wp-hook.php:348 2
  11. do_action(array) C:\apache\htdocs\oikcom\wp-includes\plugin.php:517 1
  12. do_action(oik_a2z_display,oik_letters,array) C:\apache\htdocs\wordpress\wp-content\themes\genesis-oik\functions.php:296 3
  13. genesis_oik_a2z() C:\apache\htdocs\oikcom\wp-includes\class-wp-hook.php:324 1
  14. apply_filters(,array) C:\apache\htdocs\oikcom\wp-includes\class-wp-hook.php:348 2
  15. do_action(array) C:\apache\htdocs\oikcom\wp-includes\plugin.php:517 1
  16. do_action(genesis_before_loop) C:\apache\htdocs\wordpress\wp-content\themes\genesis\lib\framework.php:59 1
  17. genesis C:\apache\htdocs\wordpress\wp-content\themes\genesis-oik\archive.php:83 0
  18. include(C:\apache\htdocs\wordpress\wp-content\themes\genesis-oik\archive.php) C:\apache\htdocs\oikcom\wp-includes\template-loader.php:106 1
  19. require_once(C:\apache\htdocs\oikcom\wp-includes\template-loader.php) C:\apache\htdocs\oikcom\wp-blog-header.php:19 1
  20. require(C:\apache\htdocs\oikcom\wp-blog-header.php) C:\apache\htdocs\oikcom\index.php:17 1
    C:\apache\htdocs\wordpress\wp-content\plugins\oik-a2z\includes\class-oik-a2z-display.php(61:0) OIK_a2z_display::query_active_term(5) 190 7 2024-11-25T18:45:17+00:00 2.392892 0.001708 cf=genesis_before_loop,oik_a2z_display 27049 38 48707 88080384/92274688 512M F=1791 en_US 1 Array

In most of the templates the hook for genesis_before_loop is genesis_oik_a2z.

function genesis_oik_a2z() {
	$args = genesis_oik_a2z_display_args();
	$taxonomy = genesis_oik_a2z_query_letter_taxonomy( "letters", $args );
	do_action( "oik_a2z_display", $taxonomy, $args );
}

This is basically the same as genesis_oik_a2z_letters() but in this scenario the original taxonomy letters is changed to oik_letters before calling oik_a2z_display.

The daily trace summary log I was looking at shows separate requests. Both produced the warnings.
I must have copied the wrong URL from history and struck lucky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant