Problem with PHP 7.4
-
There’s a problem with PHP 7.4, it throws a notice because If I don’t mark all option, it won’t be such information in the database, but then when checking it says that key doesn’t exists.
On /admin/class-extended-post-status-admin.php line 197, for each
ifcheck if array has they key, otherwise it will throw the notice.
-
Hi @skatox
thanks for the feedback. I’ll have a look at this and will come back to you.
Greetings Felix
Hi @skatox
I found some other issue while creating new statuses with the counting of posts and pages in the status overview page, but PHP 7.4 doen’t throw any notices belonging to the code part from line 183 to 214 as you said.
public function register_post_status() { $status = self::get_status(); foreach ($status as $single_status) { $term_meta = get_option("taxonomy_term_$single_status->term_id"); $args = [ 'label' => $single_status->name, 'label_count' => _n_noop($single_status->name . ' <span class="count">(%s)</span>', $single_status->name . ' <span class="count">(%s)</span>'), ]; if ($term_meta['public'] == 1) { $args['public'] = true; } else { $args['public'] = false; } if ($term_meta['show_in_admin_all_list'] == 1) { $args['show_in_admin_all_list'] = true; } else { $args['show_in_admin_all_list'] = false; } if ($term_meta['show_in_admin_status_list'] == 1) { $args['show_in_admin_status_list'] = true; } else { $args['show_in_admin_status_list'] = false; } if ($term_meta['hide_in_drop_down'] == 1) { $args['hide_in_drop_down'] = true; } else { $args['hide_in_drop_down'] = false; } register_post_status($single_status->slug, $args); } }It makes sense, that the $term_meta variable may not contain the needed information and that I have to check this beforehand, but I can not reproduce the notice in PHP. Is there anything I should add extra, to provoke this notice?
I just used the current WP version 5.3.2 as a blank setup and installed the plugin.
Thanks for your help.
Greetings Felix
Thanks for the quick reply. I reproduced it on my local server and my customer’s server. I believe both are configured to show PHP Notices by default.
Here you can see how to enable it:
https://www.php.net/manual/en/function.error-reporting.phpI have E_NOTICE_ALL added to show this kind of errors.
Btw, nice plugin 🙂 I tried to do a button on gutenberg to quickly set a button to an specific state. It would be great to have that in the future. The box is ok but my client found it to complex to set status on the dropdown and the click on save draft.
Hi,
Does this bug also applies to PHP version 7.2 or only 7.4?
Hey guys,
sorry I had a stressful week. I just wanted to let you know that I’m still investigating the problem. I’m looking forward to fix this on the weekend. Cause of the corona quarantine situation here in Germany I’ll have some more time looking at this problem ;D
@oldcrazypirate as of today I’m not aware of the bug at all, but @skatox seems to have the error explicit on 7.4. As soon as I’m able to reproduce this, I’ll test it with 7.2, 7.3 and 7.4.
Greeting Felix
Hi @skatox
have you quick fixed your code already? This should work, right?
Can you validate this?public function register_post_status() { $status = self::get_status(); foreach ($status as $single_status) { $term_meta = get_option("taxonomy_term_$single_status->term_id"); $args = [ 'label' => $single_status->name, 'label_count' => _n_noop($single_status->name . ' <span class="count">(%s)</span>', $single_status->name . ' <span class="count">(%s)</span>'), ]; if (array_key_exists('public', $term_meta) && $term_meta['public'] == 1) { $args['public'] = true; } else { $args['public'] = false; } if (array_key_exists('show_in_admin_all_list', $term_meta) && $term_meta['show_in_admin_all_list'] == 1) { $args['show_in_admin_all_list'] = true; } else { $args['show_in_admin_all_list'] = false; } if (array_key_exists('show_in_admin_status_list', $term_meta) && $term_meta['show_in_admin_status_list'] == 1) { $args['show_in_admin_status_list'] = true; } else { $args['show_in_admin_status_list'] = false; } if (array_key_exists('hide_in_drop_down', $term_meta) && $term_meta['hide_in_drop_down'] == 1) { $args['hide_in_drop_down'] = true; } else { $args['hide_in_drop_down'] = false; } register_post_status($single_status->slug, $args); } }Thank you and have a great start into this week!
Greetings Felix
Thanks! I noticed the update and seems to be fixed 🙂
The topic ‘Problem with PHP 7.4’ is closed to new replies.