#3031 closed defect (bug) (fixed)
Fatal error: Uncaught Error: [] operator not supported for strings
Reported by: | hellofromTonya | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 2.5.11 |
Component: | General | Keywords: | needs-patch |
Cc: | chrismarslender@… |
Description
There are several spots in the codebase where an element is being added to a variable that has not yet been initialized as an array. Upon upgrading to PHP 7.1, our site popped fatal error for includes/forums/functions.php
line 1800.
When a variable is not initialized to an array first, you get the following PHP Error:
Fatal error: Uncaught Error: [] operator not supported for strings...
I manually fixed it by adding the following initializers:
In includes/forums/functions.php
Line 1800 (L1969 in 2.6-alpha):
$post_stati = array();
$post_stati[] = bbp_get_public_status_id();
In includes/common/functions.php
$topics = $topic_titles = array();
$replies = $reply_titles = array();
In includes/forums/template.php
$post_stati = array();
In includes/users/template.php
Line 1648 (L1709 in 2.6-alpha)
$author_links = array();
Change History (15)
#2
@
8 years ago
- Owner set to johnjamesjacoby
- Resolution set to fixed
- Status changed from new to closed
In 6135:
This ticket was mentioned in Slack in #bbpress by sergey. View the logs.
7 years ago
This ticket was mentioned in Slack in #bbpress by zakalwe. View the logs.
7 years ago
#8
@
7 years ago
This has not been fixed, still get the error (php 7.1.7)
Fatal error: Uncaught Error: [] operator not supported for strings in C:\xampp\htdocs\themerevel\wp-content\plugins\bbpress\includes\forums\functions.php:1800 Stack trace: #0 C:\xampp\htdocs\themerevel\wp-includes\class-wp-hook.php(298): bbp_pre_get_posts_normalize_forum_visibility(Object(WP_Query)) #1 C:\xampp\htdocs\themerevel\wp-includes\class-wp-hook.php(323): WP_Hook->apply_filters('', Array) #2 C:\xampp\htdocs\themerevel\wp-includes\plugin.php(515): WP_Hook->do_action(Array) #3 C:\xampp\htdocs\themerevel\wp-includes\class-wp-query.php(1683): do_action_ref_array('pre_get_posts', Array) #4 C:\xampp\htdocs\themerevel\wp-includes\class-wp-query.php(3248): WP_Query->get_posts() #5 C:\xampp\htdocs\themerevel\wp-includes\class-wp.php(617): WP_Query->query(Array) #6 C:\xampp\htdocs\themerevel\wp-includes\class-wp.php(735): WP->query_posts() #7 C:\xampp\htdocs\themerevel\wp-includes\functions.php(955): WP->main(Array) #8 C:\xampp\htdocs\themerevel\wp-admin\includes\post.php(1072): wp(Array) #9 C:\xampp\htdocs\themerevel\wp-a in C:\xampp\htdocs\themerevel\wp-content\plugins\bbpress\includes\forums\functions.php on line 1800
#9
@
7 years ago
- Cc chrismarslender@… added
- Resolution fixed deleted
- Status changed from closed to reopened
I get the same error as @brody182 on a fresh install.
Thanks for the detailed ticket @hellofromTonya
I added PHP 7.1 Travis CI testing in r6132 earlier and will take a look at getting these instances fixed ASAP
Related: #2987