Automattic / Automattic/jetpack

Infinite Scroll: PHP notice, array to string, on customizer save

Open
#8,548 1 comment 0 reactions 0 assignees View on GitHub
[Feature] Infinite Scroll [Pri] Normal [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 14h
Merged PRs (30d)
790

Description

During testing of another PR today, I noticed PHP notices were showing up with `Array to string conversion` when I saved my widget. 🤔

So, I went to line `1031` in the `formatting.php` and dropped the following at the top of the `wp_check_invalid_utf8()` function:

```php
if ( is_array( $string ) ) {
error_log( wp_debug_backtrace_summary();
}
```

Which gave me the following:

```
[17-Jan-2018 15:26:35 UTC] require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, The_Neverending_Home_Page->ajax_response, do_action('custom_ajax_infinite_scroll'), WP_Hook->do_action, WP_Hook->apply_filters, The_Neverending_Home_Page->query, wp_footer, do_action('wp_footer'), WP_Hook->do_action, WP_Hook->apply_filters, The_Neverending_Home_Page->action_wp_footer_settings, The_Neverending_Home_Page->get_request_path, array_map, sanitize_text_field, _sanitize_text_fields, wp_check_invalid_utf8
[17-Jan-2018 15:26:35 UTC] PHP Notice: Array to string conversion in /srv/users/serverpilot/apps/ericbinnion/public/wp-includes/formatting.php on line 1035
```

When I turned off infinite scroll, I no longer had the PHP notices.

Contributor guide

Open the contributing guide

Research direction

Start in wp-includes/formatting.php at wp_check_invalid_utf8(), then trace the custom_ajax_infinite_scroll path through The_NeverEnding_Home_Page->get_request_path and sanitize_text_field. Reproduce the widget save with Infinite Scroll enabled and confirm the Array to string conversion notice no longer appears while the feature remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.