jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Undefined function (get_user_attribute) errors in admin pages

Open yohgaki opened this issue 10 years ago • 5 comments

Steps to reproduce the issue

I moved my blog from CentOS6+PHP5.6 to CentOS7+PHP7.1RC3, then I start getting Undefined function (get_user_attribute) errors in admin pages somehow. No additional module nor data changes at all.

I had to change

if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {

to

if ( false && defined( 'IS_WPCOM' ) && IS_WPCOM ) {

in

wp-content/plugins/jetpack/modules/after-the-deadline.php

I grepped all php files to see if get_user_attribute() is defined anywhere and didn't find any. Letting 'if' condition false seems to solve this issue.

What I expected

No errors.

What happened instead

Blank pages in admin pages due to undefined function.

yohgaki avatar Oct 08 '16 23:10 yohgaki

Could you tell us about your installation of WordPress? Did you build it from a specific image, or clone it from somewhere?

jeherve avatar Oct 10 '16 11:10 jeherve

Closing this for now as I can't reproduce. Let us know if you still experience the issue, and if that seems specific to your set up.

Thanks!

jeherve avatar Oct 27 '16 11:10 jeherve

You should be able to reproduce with any PHP version if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) is true. It's a simple "undefined function error". To reproduce error, just set the if condition to true.

I checked plain Wordpress tarball and my installation, there is no get_user_attribute definition found with

find . -type f | xargs grep -n 'get_user_attribute'

I suppose it's dead/legacy from the comment. // This wpcom-specific code should eventually be moved elsewhere.

yohgaki avatar Dec 18 '16 07:12 yohgaki

get_user_attribute() is a WordPress.com-specific function. That's why we check if IS_WPCOM is defined before to use that code. It is not run anywhere outside of WordPress.com, except if you intentionally set IS_WPCOM to true on your WordPress installation. If you did, you'll want to set it to false. IS_WPCOM is only meant to be used on WordPress.com.

I hope this helps.

jeherve avatar Dec 18 '16 14:12 jeherve

Ok then, something should be wrong, but I don't change single line on my wordpress except the line to disable the "if". I get this error on occasion, but it persists and I can reproduce error always when it persists.

I did more checks. It may be opcache issue. There is no "define()" not "const" in the source. It seems opcode is messed up somehow. So bug will be handled on PHP devs. Thank you for the info. (FYI, the issue is disappeared for now. I should have kept the backup that can trigger this bug)

yohgaki avatar Dec 19 '16 01:12 yohgaki