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

Plugin fatal errors when no connection #18

Closed
jtsternberg opened this issue May 21, 2015 · 4 comments
Closed

Plugin fatal errors when no connection #18

jtsternberg opened this issue May 21, 2015 · 4 comments
Labels
Milestone

Comments

@jtsternberg
Copy link

Using locally and when the wifi is disabled, I get a string of errors followed by a fatal error:

^[[1;2B[21-May-2015 02:41:15 UTC] PHP Warning: Illegal string offset 'query' in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 58
[21-May-2015 02:41:15 UTC] PHP Stack trace:
[21-May-2015 02:41:15 UTC] PHP 1. {main}() /index.php:0
[21-May-2015 02:41:15 UTC] PHP 2. require() /index.php:17
[21-May-2015 02:41:15 UTC] PHP 3. require_once() /wp-blog-header.php:16
[21-May-2015 02:41:15 UTC] PHP 4. include() /wp-includes/template-loader.php:74
[21-May-2015 02:41:15 UTC] PHP 5. get_sidebar() /wp-content/themes/organic_swell/index.php:82
[21-May-2015 02:41:15 UTC] PHP 6. locate_template() /wp-includes/general-template.php:125
[21-May-2015 02:41:15 UTC] PHP 7. load_template() /wp-includes/template.php:477
[21-May-2015 02:41:15 UTC] PHP 8. require_once() /wp-includes/template.php:501
[21-May-2015 02:41:15 UTC] PHP 9. dynamic_sidebar() /wp-content/themes/organic_swell/sidebar-left.php:15
[21-May-2015 02:41:15 UTC] PHP 10. call_user_func_array() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 11. WP_Widget->display_callback() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 12. WDS_WP_Contributions_Codex_Widget->widget() /wp-includes/widgets.php:329
[21-May-2015 02:41:15 UTC] PHP 13. WDS_WP_Contributions->display_card() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php:118
[21-May-2015 02:41:15 UTC] PHP 14. WDS_WP_Contributions_Codex->display() /wp-content/plugins/wp-contributions/wp-contributions.php:166
[21-May-2015 02:41:15 UTC] PHP 15. WDS_WP_Contributions_Codex::get_codex_items() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:123
[21-May-2015 02:41:15 UTC] PHP Notice: Uninitialized string offset: 0 in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 58
[21-May-2015 02:41:15 UTC] PHP Stack trace:
[21-May-2015 02:41:15 UTC] PHP 1. {main}() /index.php:0
[21-May-2015 02:41:15 UTC] PHP 2. require() /index.php:17
[21-May-2015 02:41:15 UTC] PHP 3. require_once() /wp-blog-header.php:16
[21-May-2015 02:41:15 UTC] PHP 4. include() /wp-includes/template-loader.php:74
[21-May-2015 02:41:15 UTC] PHP 5. get_sidebar() /wp-content/themes/organic_swell/index.php:82
[21-May-2015 02:41:15 UTC] PHP 6. locate_template() /wp-includes/general-template.php:125
[21-May-2015 02:41:15 UTC] PHP 7. load_template() /wp-includes/template.php:477
[21-May-2015 02:41:15 UTC] PHP 8. require_once() /wp-includes/template.php:501
[21-May-2015 02:41:15 UTC] PHP 9. dynamic_sidebar() /wp-content/themes/organic_swell/sidebar-left.php:15
[21-May-2015 02:41:15 UTC] PHP 10. call_user_func_array() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 11. WP_Widget->display_callback() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 12. WDS_WP_Contributions_Codex_Widget->widget() /wp-includes/widgets.php:329
[21-May-2015 02:41:15 UTC] PHP 13. WDS_WP_Contributions->display_card() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php:118
[21-May-2015 02:41:15 UTC] PHP 14. WDS_WP_Contributions_Codex->display() /wp-content/plugins/wp-contributions/wp-contributions.php:166
[21-May-2015 02:41:15 UTC] PHP 15. WDS_WP_Contributions_Codex::get_codex_items() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:123
[21-May-2015 02:41:15 UTC] PHP Warning: Illegal string offset 'usercontribs' in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 58
[21-May-2015 02:41:15 UTC] PHP Stack trace:
[21-May-2015 02:41:15 UTC] PHP 1. {main}() /index.php:0
[21-May-2015 02:41:15 UTC] PHP 2. require() /index.php:17
[21-May-2015 02:41:15 UTC] PHP 3. require_once() /wp-blog-header.php:16
[21-May-2015 02:41:15 UTC] PHP 4. include() /wp-includes/template-loader.php:74
[21-May-2015 02:41:15 UTC] PHP 5. get_sidebar() /wp-content/themes/organic_swell/index.php:82
[21-May-2015 02:41:15 UTC] PHP 6. locate_template() /wp-includes/general-template.php:125
[21-May-2015 02:41:15 UTC] PHP 7. load_template() /wp-includes/template.php:477
[21-May-2015 02:41:15 UTC] PHP 8. require_once() /wp-includes/template.php:501
[21-May-2015 02:41:15 UTC] PHP 9. dynamic_sidebar() /wp-content/themes/organic_swell/sidebar-left.php:15
[21-May-2015 02:41:15 UTC] PHP 10. call_user_func_array() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 11. WP_Widget->display_callback() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 12. WDS_WP_Contributions_Codex_Widget->widget() /wp-includes/widgets.php:329
[21-May-2015 02:41:15 UTC] PHP 13. WDS_WP_Contributions->display_card() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php:118
[21-May-2015 02:41:15 UTC] PHP 14. WDS_WP_Contributions_Codex->display() /wp-content/plugins/wp-contributions/wp-contributions.php:166
[21-May-2015 02:41:15 UTC] PHP 15. WDS_WP_Contributions_Codex::get_codex_items() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:123
[21-May-2015 02:41:15 UTC] PHP Notice: Uninitialized string offset: 0 in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 58
[21-May-2015 02:41:15 UTC] PHP Stack trace:
[21-May-2015 02:41:15 UTC] PHP 1. {main}() /index.php:0
[21-May-2015 02:41:15 UTC] PHP 2. require() /index.php:17
[21-May-2015 02:41:15 UTC] PHP 3. require_once() /wp-blog-header.php:16
[21-May-2015 02:41:15 UTC] PHP 4. include() /wp-includes/template-loader.php:74
[21-May-2015 02:41:15 UTC] PHP 5. get_sidebar() /wp-content/themes/organic_swell/index.php:82
[21-May-2015 02:41:15 UTC] PHP 6. locate_template() /wp-includes/general-template.php:125
[21-May-2015 02:41:15 UTC] PHP 7. load_template() /wp-includes/template.php:477
[21-May-2015 02:41:15 UTC] PHP 8. require_once() /wp-includes/template.php:501
[21-May-2015 02:41:15 UTC] PHP 9. dynamic_sidebar() /wp-content/themes/organic_swell/sidebar-left.php:15
[21-May-2015 02:41:15 UTC] PHP 10. call_user_func_array() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 11. WP_Widget->display_callback() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 12. WDS_WP_Contributions_Codex_Widget->widget() /wp-includes/widgets.php:329
[21-May-2015 02:41:15 UTC] PHP 13. WDS_WP_Contributions->display_card() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php:118
[21-May-2015 02:41:15 UTC] PHP 14. WDS_WP_Contributions_Codex->display() /wp-content/plugins/wp-contributions/wp-contributions.php:166
[21-May-2015 02:41:15 UTC] PHP 15. WDS_WP_Contributions_Codex::get_codex_items() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:123
[21-May-2015 02:41:15 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 58
[21-May-2015 02:41:15 UTC] PHP Stack trace:
[21-May-2015 02:41:15 UTC] PHP 1. {main}() /index.php:0
[21-May-2015 02:41:15 UTC] PHP 2. require() /index.php:17
[21-May-2015 02:41:15 UTC] PHP 3. require_once() /wp-blog-header.php:16
[21-May-2015 02:41:15 UTC] PHP 4. include() /wp-includes/template-loader.php:74
[21-May-2015 02:41:15 UTC] PHP 5. get_sidebar() /wp-content/themes/organic_swell/index.php:82
[21-May-2015 02:41:15 UTC] PHP 6. locate_template() /wp-includes/general-template.php:125
[21-May-2015 02:41:15 UTC] PHP 7. load_template() /wp-includes/template.php:477
[21-May-2015 02:41:15 UTC] PHP 8. require_once() /wp-includes/template.php:501
[21-May-2015 02:41:15 UTC] PHP 9. dynamic_sidebar() /wp-content/themes/organic_swell/sidebar-left.php:15
[21-May-2015 02:41:15 UTC] PHP 10. call_user_func_array() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 11. WP_Widget->display_callback() /wp-includes/widgets.php:1272
[21-May-2015 02:41:15 UTC] PHP 12. WDS_WP_Contributions_Codex_Widget->widget() /wp-includes/widgets.php:329
[21-May-2015 02:41:15 UTC] PHP 13. WDS_WP_Contributions->display_card() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php:118
[21-May-2015 02:41:15 UTC] PHP 14. WDS_WP_Contributions_Codex->display() /wp-content/plugins/wp-contributions/wp-contributions.php:166
[21-May-2015 02:41:15 UTC] PHP 15. WDS_WP_Contributions_Codex::get_codex_items() /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:123
[21-May-2015 02:41:15 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php:102
Stack trace:
#0 /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php(102): SimpleXMLElement->__construct('')
#1 /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php(124): WDS_WP_Contributions_Codex::get_codex_count('jtsternberg')
#2 /wp-content/plugins/wp-contributions/wp-contributions.php(166): WDS_WP_Contributions_Codex->display('jtsternberg', 5)
#3 /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex-widget.php(118): WDS_WP_Contributions->display_card(Array)
#4 /wp-includes/widgets.php(329): WDS_WP_Contributions_Codex_Widget->widget(Array, Array)
#5 [internal function]: WP_Widget->display_callback(Array, Array)
#6 in /wp-content/plugins/wp-contributions/inc/class-wds-wp-contributions-codex.php on line 102

@tw2113 tw2113 added the bug label Jun 17, 2016
@colorful-tones
Copy link

colorful-tones commented Mar 29, 2017

I'm thinking this might have something to do with the usage of wp_get_remote() for retrieving WP.org API info. We should be checking for error response and provide fallback message if someone doesn't have network to reach out to WP.org API?

Example of where this plugin uses wp_get_remote() https://github.com/WebDevStudios/WP-Contributions/blob/master/inc/class-wds-wp-contributions-codex.php#L47

@tw2113 tw2113 added this to the 1.2.0 milestone Jun 16, 2022
@emilse-webdev
Copy link

My understanding in this case, is that this plugin depends on network connection as it doesn't store any data and pulls the data / reference of the plugin / theme / core contribution from wordpress.org.

In this case our options are to store the data initially pulled and use from the stored data when there's no connection or caching data as metadata...

@tw2113 what do you think is the best path for this issue? thanks

@tw2113
Copy link
Owner

tw2113 commented Jun 17, 2022

With this one, a lot of it is going to be just reading through the notices/warnings that Justin originally pasted, and do preventive measures for them.

For example " Invalid argument supplied for foreach() in /inc/class-wds-wp-contributions-codex.php on line 58" we would want to add an is_array() check.

As per Justin's specific notes, it sounds like we're trying to pass a string into SimpleXMLElement(), perhaps as a default value that didn't get changed with the existence of network connectivity.

Instead of trying to think about this too hard, I would say a try/catch block in the area where we're trying to parse XML would be ideal, and only set the transients in that area, if we don't encounter an exception.

Alternatively, we have the option to fetch json in this area instead of xml, as this endpoint is just mediawiki https://codex.wordpress.org/api.php, in case we want to change up what and how we store the data.

@tw2113
Copy link
Owner

tw2113 commented Jun 17, 2022

Fixed as part of #30

@tw2113 tw2113 closed this as completed Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants