0

Though I've seen references to similar errors, I have yet to find one quite like my own very special error here.

SAD STORY

A parent theme produces a number of proprietary widgets. Unfortunately, these widgets are not modifiable via filter hook, so, unless I want to just hack them to make them take a tag from a certain plug-in modifying a bit of html output, they need to be re-produced via the child theme. Or anyway that was the route I took.

It seemed to be a straightforward operation: Create a new file for the new widgets, and register the new Child Widgets under new names, with the required alterations in the individual widget classes encoded in the same file (as in the parent theme). The new child widgets are all identical to the original theme's widgets, except that "child_" is added to their class statements, and the code to modify their output is added where needed.

Nothing else is changed, and, like I said, the result works fine on my development site running PHP 5.6.30/WP 4.73, but, on two remote sites, both running WP 4.73, one on 5.6.30 the other PHP 7.x, I get variations on the following crash error:

[08-Mar-2017 16:27:53 UTC] PHP Fatal error:  Uncaught Error: Call to a member function add_help_tab() on null in /web/htdocs3/pokeventurepl/home/www/wp-admin/widgets.php:51
Stack trace:
#0 /web/htdocs3/pokeventurepl/home/www/wp-content/themes/colormag-pro-child/functions.php(97): include_once()
#1 /web/htdocs3/pokeventurepl/home/www/wp-settings.php(423): include('/web/htdocs3/po...')
#2 /web/htdocs3/pokeventurepl/home/www/wp-config.php(80): require_once('/web/htdocs3/po...')
#3 /web/htdocs3/pokeventurepl/home/www/wp-load.php(37): require_once('/web/htdocs3/po...')
#4 /web/htdocs3/pokeventurepl/home/www/wp-admin/admin.php(31): require_once('/web/htdocs3/po...')
#5 /web/htdocs3/pokeventurepl/home/www/wp-admin/themes.php(10): require_once('/web/htdocs3/po...')
#6 {main}
  thrown in /web/htdocs3/pokeventurepl/home/www/wp-admin/widgets.php on line 51

The line from wp-admin/widgets.php is this one:

get_current_screen()->add_help_tab( array(

If I disable the child widgets (commenting out include_once( 'child_widgets.php' ) ; from the child theme functions.php file) there's no crash, except, of course, there aren't any child widgets to use.

The crash occurs even when there are no plugins activated. It also occurs when I disable all widgets in the parent theme.

MY PLEA

Any ideas?

0

I'm going to answer my own question, though I don't understand.. yet. I'll try to research further, and would like to see if someone else can explain.

I overwrote the wp-admin/widgets.php file in one of the remote sites - which was created with a Softaculous script - with the same file from my development site, which I created manually, and the problem cleared up.

A file comparison of the widgets.php from the other remote site and the one at my local development site says they are identical. Same result: Uploaded the widgets.php from dev to remote, over-writing the latter, and now everything's OK again.

Weird.

ADDENDUM

My only guess at this point is that it has something do with character or file encoding on a deep level. I've seen similar problems and solutions reported in relation to other files and processes. This is the only example involving widgets.php that I've seen in my research.

  • Did you check file permission? With identical files one solving problem & other causing error - permission is the only enemy I can think of. – Fayaz Mar 11 '17 at 3:09
  • Thanks, Fayaz: File permissions were never touched during either of the successful file replacement operations I mentioned. – CK MacLeod Mar 11 '17 at 3:12
  • And just to be clear, the replacement widgets.php has the same permissions as all of the other files in the directory. – CK MacLeod Mar 11 '17 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.