Closed jtsternberg closed 6 years ago
First one assumes there will always be a post object, which is not the case throughout many parts of the admin. Problem is here: https://github.com/temeritystudios/wp-bitly/blob/master/includes/functions.php#L158-L159
Notice WP's default handling to check if post object exists: https://github.com/WordPress/WordPress/blob/395667f91665f2c12d3a681136b04158ecca07de/wp-includes/link-template.php#L3782-L3785
Second notice is because this file is using the $wp
global in several places, but not actually defining the global (e.g. global $wp
) before using.
Third notice is because this file is using add_query_arg()
and that function expects at least 2 parameters. Not sure why it's being used at all in these instances, but if it is to get the current request, this will work: $current_page = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';
(notice, i'm using isset()
because in the case of wp-cli, this may be empty and will throw php notices as well)
Found some more:
[09-Mar-2018 03:48:53 UTC] PHP Stack trace:
[09-Mar-2018 03:48:53 UTC] PHP 1. {main}() /app/public/wp-admin/post.php:0
[09-Mar-2018 03:48:53 UTC] PHP 2. include() /app/public/wp-admin/post.php:174
[09-Mar-2018 03:48:53 UTC] PHP 3. do_meta_boxes() /app/public/wp-admin/edit-form-advanced.php:707
[09-Mar-2018 03:48:53 UTC] PHP 4. WPBitly_Admin->displayMetabox() /app/public/wp-admin/includes/template.php:1063
[09-Mar-2018 03:48:53 UTC] PHP Warning: array_reverse() expects parameter 1 to be array, null given in /app/public/wp-content/plugins/wp-bitly/includes/class.wp-bitly-admin.php on line 445
[09-Mar-2018 03:48:53 UTC] PHP Stack trace:
[09-Mar-2018 03:48:53 UTC] PHP 1. {main}() /app/public/wp-admin/post.php:0
[09-Mar-2018 03:48:53 UTC] PHP 2. include() /app/public/wp-admin/post.php:174
[09-Mar-2018 03:48:53 UTC] PHP 3. do_meta_boxes() /app/public/wp-admin/edit-form-advanced.php:707
[09-Mar-2018 03:48:53 UTC] PHP 4. WPBitly_Admin->displayMetabox() /app/public/wp-admin/includes/template.php:1063
[09-Mar-2018 03:48:53 UTC] PHP 5. array_reverse() /app/public/wp-content/plugins/wp-bitly/includes/class.wp-bitly-admin.php:445
[09-Mar-2018 03:48:53 UTC] PHP Warning: Invalid argument supplied for foreach() in /app/public/wp-content/plugins/wp-bitly/includes/class.wp-bitly-admin.php on line 445
[09-Mar-2018 03:48:53 UTC] PHP Stack trace:
[09-Mar-2018 03:48:53 UTC] PHP 1. {main}() /app/public/wp-admin/post.php:0
[09-Mar-2018 03:48:53 UTC] PHP 2. include() /app/public/wp-admin/post.php:174
[09-Mar-2018 03:48:53 UTC] PHP 3. do_meta_boxes() /app/public/wp-admin/edit-form-advanced.php:707
[09-Mar-2018 03:48:53 UTC] PHP 4. WPBitly_Admin->displayMetabox() /app/public/wp-admin/includes/template.php:1063
[09-Mar-2018 03:48:53 UTC] PHP Warning: max(): Array must contain at least one element in /app/public/wp-content/plugins/wp-bitly/includes/class.wp-bitly-admin.php on line 450
[09-Mar-2018 03:48:53 UTC] PHP Stack trace:
[09-Mar-2018 03:48:53 UTC] PHP 1. {main}() /app/public/wp-admin/post.php:0
[09-Mar-2018 03:48:53 UTC] PHP 2. include() /app/public/wp-admin/post.php:174
[09-Mar-2018 03:48:53 UTC] PHP 3. do_meta_boxes() /app/public/wp-admin/edit-form-advanced.php:707
[09-Mar-2018 03:48:53 UTC] PHP 4. WPBitly_Admin->displayMetabox() /app/public/wp-admin/includes/template.php:1063
[09-Mar-2018 03:48:53 UTC] PHP 5. max() /app/public/wp-content/plugins/wp-bitly/includes/class.wp-bitly-admin.php:450
You can duplicate if you run this plugin locally and disable your internet connection. Basically, there needs to be handling for if/when wpbitly_get()
returns an empty response.
Look at all the things I could've avoided had I been testing this with WP_DEBUG on during the last updates. No excuses, that's just an easy mistake to avoid.
Thanks for bringing this to my attention, hopefully I can get on top of these in the coming days.
With recent release, there are notices in the debug.log on almost every admin page.
and
and