Skip to:
Content

Opened 2 years ago

Closed 2 years ago

Last modified 21 months ago

#2987 closed defect (fixed)

PHP 7.1 & PHP "Nightly" error: [] operator not supported for strings

Reported by: netweb Owned by: netweb
Milestone: 2.6 Priority: normal
Severity: normal Version:
Component: General Keywords: commit has-patch
Cc:

Description

bbPress is currently seeing 3 instances of the error [] operator not supported for strings on PHP 7.1 and PHP "nightly" jobs on Travis CI

There were 3 errors:

1) BBP_Tests_Forums_Template_Forum::test_bbp_get_forum_permalink
Error: [] operator not supported for strings

/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:2250
/tmp/wordpress/src/wp-includes/plugin.php:602
/tmp/wordpress/src/wp-includes/class-wp-query.php:1682
/tmp/wordpress/src/wp-includes/class-wp-query.php:3238
/tmp/wordpress/src/wp-includes/post.php:1595
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1527
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1946
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:73
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/includes/factory.php:31
/tmp/wordpress/tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php:32
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/testcases/forums/template/forum.php:87

2) BBP_Tests_Forums_Template_Visibility::test_bbp_get_forum_visibility
Error: [] operator not supported for strings

/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:2250
/tmp/wordpress/src/wp-includes/plugin.php:602
/tmp/wordpress/src/wp-includes/class-wp-query.php:1682
/tmp/wordpress/src/wp-includes/class-wp-query.php:3238
/tmp/wordpress/src/wp-includes/post.php:1595
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1527
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1946
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:73
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/includes/factory.php:31
/tmp/wordpress/tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php:32
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/testcases/forums/template/visibility.php:28

3) BBP_Tests_Forums_Template_Visibility::test_bbp_is_forum_visibility
Error: [] operator not supported for strings

/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:2250
/tmp/wordpress/src/wp-includes/plugin.php:602
/tmp/wordpress/src/wp-includes/class-wp-query.php:1682
/tmp/wordpress/src/wp-includes/class-wp-query.php:3238
/tmp/wordpress/src/wp-includes/post.php:1595
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1527
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:1946
/tmp/wordpress/src/wp-content/plugins/bbPress/src/includes/forums/functions.php:73
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/includes/factory.php:31
/tmp/wordpress/tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php:32
/tmp/wordpress/src/wp-content/plugins/bbPress/tests/phpunit/testcases/forums/template/visibility.php:52

Attachments (1)

2987.diff (516 bytes) - added by thebrandonallen 2 years ago.

Download all attachments as: .zip

Change History (8)

#1 @netweb
2 years ago

Related: #2973

@thebrandonallen
2 years ago

#2 @thebrandonallen
2 years ago

  • Keywords commit has-patch added
  • Milestone changed from Awaiting Review to 2.6

WP_Query:get() defaults to returning an empty string if the requested key isn't set. However, you can pass a default return value. Attached patch sets the default return to an empty array. Tests now pass.

#3 @netweb
2 years ago

  • Owner set to netweb
  • Resolution set to fixed
  • Status changed from new to closed

In 6113:

General: Set the default return to an empty array in $posts_query->get() in bbp_pre_get_posts_normalize_forum_visibility()

This changeset fixes PHP 7.1 warnings [] operator not supported for strings due to WP_Query:get() defaulting to returning an empty string if the requested key isn't set. However, you can pass a default return value. This commit sets the default return to an empty array.

Props thebrandonallen.
Fixes #2987.

#4 @johnjamesjacoby
2 years ago

In 6212:

Parser: PHP 7.1 compatibility fixes to parser.php

Props xknown. Fixes #2973. See #2987.

#5 @netweb
2 years ago

Merged r6212 upstream into bbPress' fork of NBBC https://github.com/bbpress/NBBC/pull/1

#6 @netweb
21 months ago

In 6417:

General: Set the default return to an empty array in $posts_query->get() in bbp_pre_get_posts_normalize_forum_visibility()

This changeset fixes PHP 7.1 warnings [] operator not supported for strings due to WP_Query:get() defaulting to returning an empty string if the requested key isn't set. However, you can pass a default return value. This commit sets the default return to an empty array.

Props thebrandonallen.
See #2987.

Merges [6113] to the 2.5 branch.

#7 @netweb
21 months ago

In 6418:

Parser: PHP 7.1 compatibility fixes to parser.php

Props xknown.
See #2973, #2987.

Merges [6212] to the 2.5 branch.

Note: See TracTickets for help on using tickets.