Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#48008 closed defect (bug) (wontfix)

'Illegal string offset \'display_name\'',

Reported by: j3gaming's profile j3gaming Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.1
Component: Plugins Keywords:
Focuses: Cc:

Description

I have some script error reporting set on my WordPress installation.
Page: wp-admin/plugins.php
Plugin: Advanced Custom Fields PRO
Click "View version 5.8.4 details"

Here is the technical dump:
array (

0 =>
array (

'file' => 'C:
inetpub
wwwroot
wp-admin
includes
plugin-install.php',
'line' => 737,
'function' => 'CustomStackTrace',
'args' =>
array (

0 => 2,
1 => 'Illegal string offset \'display_name\,
2 => 'C:
inetpub
wwwroot
wp-admin
includes
plugin-install.php',
3 => 737,
4 =>
array (

'tab' => 'plugin-information',
'api' =>
(object) array(

'name' => 'Advanced Custom Fields PRO',
'slug' => 'advanced-custom-fields-pro',
'version' => '5.8.4',
'homepage' => 'https://www.advancedcustomfields.com',
'author' => 'Elliot Condon',
'author_url' => 'https://www.advancedcustomfields.com',
'contributors' => 'elliotcondon',
'requires' => '4.7.0',
'requires_php' => '5.4',
'tested' => '5.2',
'added' => '2014-07-11',
'last_updated' => '2019-09-04',
'description' => '

See attached screenshot

Attachments (1)

Screen Shot 2019-09-09 at 1.40.52 PM.png (82.9 KB) - added by j3gaming 5 years ago.
See the area on the right?

Download all attachments as: .zip

Change History (10)

@j3gaming
5 years ago

See the area on the right?

#1 follow-up: @whyisjake
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This doesn't look like a core issue, but something that should be opened in the plugin forums.

#2 in reply to: ↑ 1 @tobifjellner
5 years ago

Replying to whyisjake:

This doesn't look like a core issue, but something that should be opened in the plugin forums.

Rather: with the support channel of that commercial plugin.

#3 @garrett-eclipse
5 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Looking into this it appears to be a back-compat issue with the introduction of the plugin_information API upgrade to 1.2 which expanded and introduced the display_name into the response.

Specifically [42631] of #43192 for the core change and [meta111] for the API.

Previous to this change if a third-party such as ACF used the plugins_api filter to replace the response they could just use a username string or array of username strings like;
"contributors":"elliotcondon"

Since the core change the contributors returned are required to be a dictionary with 'profile', 'avatar' and 'display_name' provided as follows;
"contributors":{"elliotcondon":{"profile":"https:\/\/profiles.wordpress.org\/elliotcondon","avatar":"https:\/\/secure.gravatar.com\/avatar\/533079e82e526367047100d8019cb9a7?s=96&d=monsterid&r=g","display_name":"elliotcondon"}

So I guess the question is, for back-compact, should the loop check if it's a string or a dictionary for the contributor in the loop and if a string revert to the old way of providing their name/avatar/link?

Pinging @dd32 for thoughts as he mentioned in #43192 to mention him if anything came up. I presume other plugins using the plugins_api filter may also be experiencing this unless they were aware of the 1.2 API upgrade and change to contributors format.

Last edited 5 years ago by SergeyBiryukov (previous) (diff)

#4 @SergeyBiryukov
5 years ago

  • Milestone set to Awaiting Review

#5 @dd32
5 years ago

So I guess the question is, for back-compact, should the loop check if it's a string or a dictionary for the contributor in the loop and if a string revert to the old way of providing their name/avatar/link?

Given the length of time between change and report, in this case I don't think I'd advocate adding any back-compat code here, especially as the warning will go away once the plugin in question is updated (I assume)

Unfortunately the plugins_api filter isn't very forgiving, it doesn't really have an inbuilt method for versioning, and those who implement it really need to keep up-to-speed with the core changes IMHO.

If this was reported closer to the implementation time, I'd not have been against writing code such as the following

$res = apply_filters( 'plugins_api', false, $action, $args );
if ( $res ) {
  if ( $res['contributors'] is set and is a flat array ) {
    // "upgrade" the result to a `{ profile: .., avatar: ..default, disply_name: $value }`
  }
}

#6 @garrett-eclipse
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

Thanks Dion, I appreciate you feeding back here and agree it's been a long time so back-compat would be a little late.

I'm reclosing as wontfix with a note to developers;
If replacing plugins_api with custom contributors ensure the format is as follows;

"contributors": {
    "username": { 
        "profile": "https:\/\/profiles.wordpress.org\/username",
        "avatar": "https:\/\/secure.gravatar.com\/avatar\/XXX?s=96&d=monsterid&r=g",
        "display_name":"Display Name"
    }
}

*Using the username as key and supplying the profile (URL), avatar(IMG URL) and display_name as children.

#7 @garrett-eclipse
5 years ago

  • Version changed from 5.2.3 to 5.1

#8 @garrett-eclipse
5 years ago

FYI @j3gaming I just got an update from Elliot and this has been addressed in his API, testing the issue is resolved for ACF Pro now. Cheers

#9 @j3gaming
5 years ago

Thanks @garrett-eclipse and team for checking into all this.
If it's not a check to be added to the core I see it was talked about, and I understand the decision.

Thanks for checking in with ACF and having them fix that up.

Close whenever you need :)

Note: See TracTickets for help on using tickets.