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

New Plugin Activation - Accessing array offset on value of type bool #198

Closed
TylerB24890 opened this issue Feb 24, 2021 · 4 comments · Fixed by #323
Closed

New Plugin Activation - Accessing array offset on value of type bool #198

TylerB24890 opened this issue Feb 24, 2021 · 4 comments · Fixed by #323
Assignees
Labels

Comments

@TylerB24890
Copy link

TylerB24890 commented Feb 24, 2021

Describe the bug
On plugin activation, a notice appears at the top of the admin panel: Notice: Trying to access array offset on value of type bool. This happens when a user does not have an account setup yet with the plugin, which I would imagine is very common on first activation of the plugin.

Note: This was tested on a fresh WP installation setup and configured with wp-local-docker-v2

Steps to Reproduce

  1. Install the Brightcove Video Connect plugin on any WordPress installation that does not yet have an account setup for Brightcove.
  2. Activate Plugin.
  3. Every page in the admin panel shows the same notice until an account is added.

Expected behavior
Activate plugin to see an Admin notice to add a Brightcove Account. The Admin notice is present, but as is the PHP notice.

Screenshots
Screen Shot 2021-02-24 at 7 07 53 AM

Environment information

  • Device: 2020 MacBook Pro 16"
  • OS: MacOS 10.15.7 (Catalina)
  • Browser and version: Chrome 88.0.4324.182
  • WordPress version: 5.6.2
Site Health Info: ### wp-core ###

version: 5.6.2
site_language: en_US
user_language: en_US
timezone: +00:00
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: open
environment_type: production
user_count: 2
dotorg_communication: true

wp-paths-sizes

wordpress_path: /var/www/html
wordpress_size: loading...
uploads_path: /var/www/html/wp-content/uploads
uploads_size: loading...
themes_path: /var/www/html/wp-content/themes
themes_size: loading...
plugins_path: /var/www/html/wp-content/plugins
plugins_size: loading...
database_size: loading...
total_size: loading...

wp-active-theme

name: 10up Theme Scaffold
version: 0.1.0
author: 10up
author_website: https://10up.com
parent_theme: none
theme_features: core-block-patterns, automatic-feed-links, disable-custom-colors, disable-custom-font-sizes, editor-gradient-presets, disable-custom-gradients, editor-color-palette, post-thumbnails, title-tag, html5, editor-font-sizes, menus
theme_path: /var/www/html/wp-content/themes/bx-intranet
auto_update: Disabled

wp-mu-plugins (1)

bx-base.php: author: 10up, version: 0.1.0

wp-plugins-active (2)

Brightcove Video Connect: version: 2.1.2, author: 10up, Auto-updates disabled
ElasticPress: version: 3.5.4, author: 10up, Auto-updates disabled

wp-plugins-inactive (1)

Secure Media: version: 1.0.5, author: 10up, Auto-updates disabled

wp-media

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1690
imagemagick_version: ImageMagick 6.9.10-86 Q16 x86_64 2020-01-13 https://imagemagick.org
file_uploads: File uploads is turned off
post_max_size: 150m
upload_max_filesize: 150m
max_effective_size: 150 MB
max_file_uploads: 20
imagick_limits:
imagick::RESOURCETYPE_AREA: 4 GB
imagick::RESOURCETYPE_DISK: 9.2233720368548E+18
imagick::RESOURCETYPE_FILE: 786432
imagick::RESOURCETYPE_MAP: 4 GB
imagick::RESOURCETYPE_MEMORY: 2 GB
imagick::RESOURCETYPE_THREAD: 1
gd_version: 2.2.5
ghostscript_version: not available

wp-server

server_architecture: Linux 4.19.121-linuxkit x86_64
httpd_software: nginx/1.19.5
php_version: 7.4.13 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 30
memory_limit: 128M
admin_memory_limit: 256M
max_input_time: 60
upload_max_filesize: 150m
php_post_max_size: 150m
curl_version: 7.61.1 OpenSSL/1.1.1c
suhosin: false
imagick_availability: true
pretty_permalinks: true

wp-database

extension: mysqli
server_version: 5.7.32
client_version: mysqlnd 7.4.13

wp-constants

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /var/www/html/wp-content
WP_PLUGIN_DIR: /var/www/html/wp-content/plugins
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: true
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: true
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined

wp-filesystem

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable

Additional context

  • This was setup and tested on two different sites. The first was a fresh WP installation setup and configured with WP Local Docker V2. The second was an established site with numerous authors and posts -- same result.
  • I have already implemented and tested a fix locally. Happy to submit a Pull Request if this is deemed in fact a bug.
@jeffpaul
Copy link
Member

jeffpaul commented Mar 3, 2021

@TylerB24890 I'm curious what your fix approach is. I think we'd ideally want to detect that an account is not yet setup and direct new installs to the correct screen/page/site to create an account such that the plugin functions as expected.

@mehul0810
Copy link

I did take a quick look at this issue. Here are some of the findings and possible approaches to the fix.

First of all, this issue can be replicated with PHP 7.4 or greater.

Possible solutions

  1. For PHP 7 or greater, we can use a null coalescing operator to resolve this.
  2. For PHP 5.6 or lesser, we can use a ternary operator to resolve this.

So, the solution is dependent on the minimum PHP version we would like to support for this plugin. I was not able to find the information about the minimum PHP version support for this plugin.

@oscarssanchez
Copy link
Contributor

I've added php compatibility tests here: #262

Since the plugin is compliant with 5.6 compatibility and WordPress core still supports it https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/ I think we should go with the PHP 5.6 solution.

@oscarssanchez
Copy link
Contributor

Diving a bit deeper into it I think the actual solution is to not load those scripts if account has not been configured. If we have not configured a Brightcove account, we don't need to localize data (and also we should not load other parts of the plugin as well).

At the same time, I think this is a great opportunity to conditionally fix the same problem for other scenarios. Say you are an editor who can't create new accounts, then files belonging to those features should not load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants