Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#41540 closed defect (bug) (fixed)

The rich Text widget cannot be extended

Reported by: hmabpera's profile hmabpera Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.8
Component: Widgets Keywords: has-patch needs-testing
Focuses: Cc:

Description

Since the automatic update of WordPress 4.8.1 I noticed that the widgets in the backend of our website have disappeared. they are present on the web pages but not on the Widgets admin page.
I am going to restore WordPress 4.8

Attachments (4)

Missing Widgets.JPG (134.1 KB) - added by hmabpera 7 years ago.
The red arrow points to the right side of the screen where widgets were missing in 4.8.1
Missing Widgets2.JPG (63.0 KB) - added by hmabpera 7 years ago.
This file shows the incomplete list of Available Widgets in the left column
41540.0.diff (2.7 KB) - added by westonruter 7 years ago.
https://github.com/xwp/wordpress-develop/pull/244
41540.1.diff (4.1 KB) - added by westonruter 7 years ago.
Prevent Text widget underscore templates from being output more than once: https://github.com/xwp/wordpress-develop/pull/244/commits/6844c84

Download all attachments as: .zip

Change History (43)

#1 follow-ups: @westonruter
7 years ago

  • Component changed from General to Widgets
  • Keywords reporter-feedback added

@hmabpera Thanks for the report. What plugins do you have active? Which theme is active?

Are there error messages in the logs? Are there error messages in the browser console?

Do widgets load for you in the Customizer?

#2 follow-up: @westonruter
7 years ago

@hmabpera also, does the widgets admin screen fail to load or fail to fully load, is that what you mean by disappear? Or does the admin screen load fully but all of the sidebars are empty?

#3 in reply to: ↑ description @hmabpera
7 years ago

  • Resolution set to invalid
  • Status changed from new to closed

After I did the restore of WordPress 4.8, the widgets are in the Admin area.
I think this shows that the problem is in WordPress 4.8.1

Replying to hmabpera:

Since the automatic update of WordPress 4.8.1 I noticed that the widgets in the backend of our website have disappeared. they are present on the web pages but not on the Widgets admin page.
I am going to restore WordPress 4.8

#4 in reply to: ↑ 2 @hmabpera
7 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

The Widgets admin screen loads with the Available widgets visible but the widgets which I have created are not visible in the Admin area. They do appear on my web pages though.

Thanks for your reply.

Replying to westonruter:

@hmabpera also, does the widgets admin screen fail to load or fail to fully load, is that what you mean by disappear? Or does the admin screen load fully but all of the sidebars are empty?

#5 in reply to: ↑ 1 ; follow-up: @hmabpera
7 years ago

The theme I'm using is the 2011 theme.
There were no error messages that I saw.
I'm content that I have the widgets I created back again but I don't have any of the fixes you put into WordPress 4.8.1

Replying to westonruter:

@hmabpera Thanks for the report. What plugins do you have active? Which theme is active?

Are there error messages in the logs? Are there error messages in the browser console?

Do widgets load for you in the Customizer?

#6 in reply to: ↑ 1 @hmabpera
7 years ago

The widgets did not load in the Customizer either.

Replying to westonruter:

@hmabpera Thanks for the report. What plugins do you have active? Which theme is active?

Are there error messages in the logs? Are there error messages in the browser console?

Do widgets load for you in the Customizer?

@hmabpera
7 years ago

The red arrow points to the right side of the screen where widgets were missing in 4.8.1

#7 follow-up: @westonruter
7 years ago

@hmabpera so you are using the Twenty Eleven theme, but which plugins do you have active?

#8 in reply to: ↑ 5 @hmabpera
7 years ago

I tried to attach a Screen Printout of the Widgets page as it appears in WP 4.8 and arrow pointing to what is missing in 4.8.1

Replying to hmabpera:

The theme I'm using is the 2011 theme.
There were no error messages that I saw.
I'm content that I have the widgets I created back again but I don't have any of the fixes you put into WordPress 4.8.1

Replying to westonruter:

@hmabpera Thanks for the report. What plugins do you have active? Which theme is active?

Are there error messages in the logs? Are there error messages in the browser console?

Do widgets load for you in the Customizer?

#9 follow-ups: @westonruter
7 years ago

@hmabpera we will need to know all of the plugins you have active. Also, are you able to deactivate all plugins and then do the upgrade to 4.8.1? Does the issue occur then as well?

We need to be able to recreate your environment and reproduce the issue in order to be able to help you.

#10 in reply to: ↑ 7 @hmabpera
7 years ago

Replying to westonruter:
Catch IDs, Disable Comments, Enhanced Admin Bar with Codex Search, Envira Gallery,Google Analytics, My Calendar, Really Simpe SSL, Really Simple SSL pro, SendGrid, Simple Access Control, Slideshow, TablePress, TablePress Etension: Responsive Tables, Theme My Login, UpdraftPlus, WeatherUnderground, Wordfence Security and WPForms

@hmabpera so you are using the Twenty Eleven theme, but which plugins do you have active?

#11 in reply to: ↑ 9 @hmabpera
7 years ago

We do not have a test environment. I'm afraid deactivating all of these plugins at once would make our website unusable. Can you point to a likely candidate you suspect?

Replying to westonruter:

@hmabpera we will need to know all of the plugins you have active. Also, are you able to deactivate all plugins and then do the upgrade to 4.8.1? Does the issue occur then as well?

We need to be able to recreate your environment and reproduce the issue in order to be able to help you.

#12 in reply to: ↑ 9 ; follow-up: @hmabpera
7 years ago

UH OH, I just got another automatic update of Word Press 4.8.1 and the widget definitions are gone again.
This isn't good. Can you help?

Replying to westonruter:

@hmabpera we will need to know all of the plugins you have active. Also, are you able to deactivate all plugins and then do the upgrade to 4.8.1? Does the issue occur then as well?

We need to be able to recreate your environment and reproduce the issue in order to be able to help you.

#13 follow-up: @westonruter
7 years ago

@hmabpera first add define( 'AUTOMATIC_UPDATER_DISABLED', true ); to your wp-config.php and then downgrade to WordPress 4.8 again. It won't automatically upgrade again until you remove that constant.

#14 in reply to: ↑ 12 @hmabpera
7 years ago

I notice now that the 4.8.1 problem is back, the list of Available Widgets is incomplete.
I will try to attach another file.

Replying to hmabpera:

UH OH, I just got another automatic update of Word Press 4.8.1 and the widget definitions are gone again.
This isn't good. Can you help?

Replying to westonruter:

@hmabpera we will need to know all of the plugins you have active. Also, are you able to deactivate all plugins and then do the upgrade to 4.8.1? Does the issue occur then as well?

We need to be able to recreate your environment and reproduce the issue in order to be able to help you.

@hmabpera
7 years ago

This file shows the incomplete list of Available Widgets in the left column

#15 @westonruter
7 years ago

@hmabpera that is helpful. Notice that the output stops at the "Loggedin Text" widget, that there is no description. I believe this indicates an error in that widget, though it could also be that this widget just doesn't have a description.

#16 follow-up: @westonruter
7 years ago

@hmabpera there is likely an error being written into your server's PHP error log. That would be helpful to share.

#17 @westonruter
7 years ago

@hmabpera I am able to reproduce the issue. The problem is in the simple-access-control plugin. I'm looking into why.

#18 follow-up: @westonruter
7 years ago

The errors that is being raised is this:

Deprecated: Non-static method WP_Widget_Text::form() should not be called statically, assuming $this from incompatible context in /app/public/wp-content/plugins/simple-access-control/simple-access-control.php on line 440

Fatal error: Call to undefined method Logggedin_Widget_Text::is_legacy_instance() in /app/public/wp-includes/widgets/class-wp-widget-text.php on line 351

The problem is that the plugin is not properly extending the widget. I can provide a patched version for you.

#19 in reply to: ↑ 13 @hmabpera
7 years ago

Thanks for getting back to me.

I am not too familiar with php code but I can do this.
Where in the config file should I put this?
There are different sections:
/

  • The base configurations of the WordPress. *
  • This file has the following configurations: MySQL settings, Table Prefix,
  • Secret Keys, WordPress Language, and ABSPATH. You can find more information
  • by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
  • wp-config.php} Codex page. You can get the MySQL settings from your web host. *
  • This file is used by the wp-config.php creation script during the
  • installation. You don't have to use the web site, you can just copy this file
  • to "wp-config.php" and fill in the values. *
  • @package WordPress */

Replying to westonruter:

@hmabpera first add define( 'AUTOMATIC_UPDATER_DISABLED', true ); to your wp-config.php and then downgrade to WordPress 4.8 again. It won't automatically upgrade again until you remove that constant.

#20 in reply to: ↑ 18 @hmabpera
7 years ago

Thanks for this research.
I would appreciate the patch.
At this point I have WP 4.8.1 running, no widgets. I haven't done anything with the wp_config file.

I'm hoping I can just use the Simple Access Control patch.
thanks soo much.

Replying to westonruter:

The errors that is being raised is this:

Deprecated: Non-static method WP_Widget_Text::form() should not be called statically, assuming $this from incompatible context in /app/public/wp-content/plugins/simple-access-control/simple-access-control.php on line 440

Fatal error: Call to undefined method Logggedin_Widget_Text::is_legacy_instance() in /app/public/wp-includes/widgets/class-wp-widget-text.php on line 351

The problem is that the plugin is not properly extending the widget. I can provide a patched version for you.

#21 in reply to: ↑ 16 @hmabpera
7 years ago

I cannot find the PHP error log.
I am logged into cpanel and I looked in the logs directory.

I should also tell you that I recently installed the Theme My Login plugin. Just want to mention that since my problem seems related to a login plugin. :(

Replying to westonruter:

@hmabpera there is likely an error being written into your server's PHP error log. That would be helpful to share.

#22 follow-up: @westonruter
7 years ago

  • Milestone changed from Awaiting Review to 4.8.2
  • Summary changed from WordPress 4.8.1 caused Widgets to disappear to Plugin extending rich Text widget causes fatal error

@hmabpera you don't need to supply info from the PHP error log now. I was able to reproduce the problem and it is in the Simple Access Control plugin. It is not properly extending the Text widget and this is the reason for the error. I'm working on a workaround plugin to make the plugin do the right thing.

I also discovered that the JS for the rich Text widget is not accounting for widgets that extend WP_Widget_Text, so even if the Simple Access Control extended the Text widget properly, there would still be an issue. This may be what is reported in #41536 as well.

#23 in reply to: ↑ 22 @hmabpera
7 years ago

Thanks for the update. I do appreciate your hanging in here with this for us.
Am I correct in thinking that this problem is limited to the admin widget area?
I'll check back with you in the morning.

Replying to westonruter:

@hmabpera you don't need to supply info from the PHP error log now. I was able to reproduce the problem and it is in the Simple Access Control plugin. It is not properly extending the Text widget and this is the reason for the error. I'm working on a workaround plugin to make the plugin do the right thing.

I also discovered that the JS for the rich Text widget is not accounting for widgets that extend WP_Widget_Text, so even if the Simple Access Control extended the Text widget properly, there would still be an issue. This may be what is reported in #41536 as well.

#24 @westonruter
7 years ago

@hmabpera yes, I believe it is limited to the widget admin area and the Customizer, yes.

Here is the first step at a workaround plugin that will prevent the fatal error: https://github.com/westonruter/simple-access-control-text-widget-workaround

Last edited 7 years ago by westonruter (previous) (diff)

#25 @westonruter
7 years ago

@hmabpera and here is the second plugin that you'll need, which will ensure that Text widget subclasses get initialized in JS: https://github.com/xwp/wp-core-text-widget-extensibility

Last edited 7 years ago by westonruter (previous) (diff)

#26 @westonruter
7 years ago

  • Summary changed from Plugin extending rich Text widget causes fatal error to The rich Text widget cannot be extended

Here is plugin that shows how the Text widget should be exended:

<?php
require_once ABSPATH . '/wp-includes/widgets/class-wp-widget-text.php';

class Extended_Text_Widget extends WP_Widget_Text {
        function __construct() {
                parent::__construct();
                $this->id_base = 'extended_text';
                $this->name = __( 'Extended Text' );
                $this->option_name = 'widget_' . $this->id_base;
                $this->widget_options['description'] = __( 'Extended arbitrary text.' );
                $this->control_options['id_base'] = $this->id_base;
        }
}

add_action( 'widgets_init', function() {
        register_widget( 'Extended_Text_Widget' );
} );

This paired with the this plugin ensures that the title and TinyMCE fields will be initialized.

#27 @westonruter
7 years ago

  • Keywords has-patch needs-testing added
  • Owner set to westonruter
  • Status changed from reopened to accepted

The patched version of text-widgets.js in this plugin can be found in core patch form in 41540.0.diff and in a pull request.

Last edited 7 years ago by westonruter (previous) (diff)

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 years ago

#29 follow-up: @westonruter
7 years ago

Note: I've reached out to the author of Simple Access Control to alert them of the issue with how the Text widget is incorrectly extended in the plugin.

#30 in reply to: ↑ 29 ; follow-up: @hmabpera
7 years ago

Thanks for this information.
Since we have no testing environment, I will work on implementing the fix this evening.
i had thought of notifying the Simple Access Control developer, too.

I am not a plugin developer so I don't know exactly what to do with these files.
Are you suggesting that I substitute the two files: simple-access-control-workaround.php and text-widgets-patched.js for the files of the same name (w/o the patched part) on the server?

If so, here's my plan:

  1. download the two original files so I have them in case I make a mistake
  2. replace them with your 2 files changing the names (or not?) Can I leave the "patched part in the names?
  3. look for my widgets

Again, thank you very much for your quick and expert response. I hope you get a bonus.

Replying to westonruter:

Note: I've reached out to the author of Simple Access Control to alert them of the issue with how the Text widget is incorrectly extended in the plugin.

#31 in reply to: ↑ 30 @westonruter
7 years ago

The two files are plugins. So you will not replace any files on the server. I'll follow up with instructions in a bit.

Replying to hmabpera:

I am not a plugin developer so I don't know exactly what to do with these files.
Are you suggesting that I substitute the two files: simple-access-control-workaround.php and text-widgets-patched.js for the files of the same name (w/o the patched part) on the server?

If so, here's my plan:

  1. download the two original files so I have them in case I make a mistake
  2. replace them with your 2 files changing the names (or not?) Can I leave the "patched part in the names?
  3. look for my widgets

#32 @westonruter
7 years ago

By the way, I did a search across all themes and plugins that extend WP_Widget_Text and there are 8 plugins and 2 themes that do so:

WordPress-Plugin-Directory-Slurper/plugins/admium/class-admium-widgets.php:16: extends WP_Widget_Text
WordPress-Plugin-Directory-Slurper/plugins/admium/class-admium-widgets.php:32: extends WP_Widget_Text
WordPress-Plugin-Directory-Slurper/plugins/better-text-widget/better-text-widget.php:13: extends WP_Widget_Text
WordPress-Plugin-Directory-Slurper/plugins/content-sidebars/content-sidebars.php:1569: extends WP_Widget_Text
WordPress-Plugin-Directory-Slurper/plugins/hackadelic-discreet-text-widget/hackadelic-discreet-text-widget.php:15: extends WP_Widget_Text
WordPress-Plugin-Directory-Slurper/plugins/simple-access-control/simple-access-control.php:432:WP_Widget_Text::
WordPress-Plugin-Directory-Slurper/plugins/simple-access-control/simple-access-control.php:436:WP_Widget_Text::
WordPress-Plugin-Directory-Slurper/plugins/simple-access-control/simple-access-control.php:440:WP_Widget_Text::
WordPress-Plugin-Directory-Slurper/plugins/tm-woocommerce-package/includes/widgets/class-tm-about-store-widget.php:14: extends WP_Widget_Text
WordPress-Theme-Directory-Slurper/themes/annotum-base/functions/widgets.php:12: extends WP_Widget_Text
WordPress-Theme-Directory-Slurper/themes/shprink-one/functions/Widget/Text.php:3: extends WP_Widget_Text

The simple-access-control plugin is the one we're looking at here. I'll check the others later. They may not need workarounds.

#33 follow-up: @westonruter
7 years ago

@hmabpera ok, I've moved the plugins into their own proper GitHub repos:

So now, here is what you do. Download the two plugins by clicking on the ZIP files that are linked to on the following release pages:

You should then have two files on your system:

  • simple-access-control-text-widget-workaround.zip
  • wp-core-text-widget-extensibility.zip

Then you can install these plugins into your WordPress site by:

  1. Go to Plugins > Add New in the WP Admin
  2. Click "Upload Plugin"
  3. Select one of the plugin ZIP files and click "Install now".
  4. Click "Activate Plugin" on the next screen.
  5. Go back to step 1 and do the same for the other plugin.

When you are done, you should have two new plugins showing in your plugin list:

  • Simple Access Control Logggedin Text Widget Workaround
  • Workaround for Simple Access Control plugin not extending Text widget properly.

I've tested these and confirm that they fix the problem as I was able to reproduce. However, I'll share the requisite disclaimer that as open source software licensed under GPLv2:

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
Version 0, edited 7 years ago by westonruter (next)

#34 @westonruter
7 years ago

In regards to the plugins that extend the Text widget, the following are no longer maintained:

So I will not dig into them.

These plugins are active:

The two themes are both inactive, but I'll check them out regardless:

#35 @westonruter
7 years ago

The three active plugins and two themes have extended Text widgets that work as expected, though the Discreet Text widget in the content-sidebars plugin depends on 41540.0.diff to initialize.

#36 in reply to: ↑ 33 @hmabpera
7 years ago

Thank you again. I installed the plugins by uploading your zip files as you directed. .I'm very glad I didn't have to edit any WP files. My widget area is back. I learned quite a bit from you, too.
You did an excellent job correcting the problem we had. Very appreciative.
We use the widget area a lot. :) As far as I'm concerned you can call this one RESOLVED.
A pleasure working with you.

Replying to westonruter:

@hmabpera ok, I've moved the plugins into their own proper GitHub repos:

So now, here is what you do. Download the two plugins by clicking on the latest release ZIP files that are linked to on the following release pages:

You should then have two files on your system:

  • simple-access-control-text-widget-workaround.zip
  • wp-core-text-widget-extensibility.zip

Then you can install these plugins into your WordPress site by:

  1. Go to Plugins > Add New in the WP Admin
  2. Click "Upload Plugin"
  3. Select one of the plugin ZIP files and click "Install now".
  4. Click "Activate Plugin" on the next screen.
  5. Go back to step 1 and do the same for the other plugin.

When you are done, you should have two new plugins showing in your plugin list:

  • Simple Access Control Logggedin Text Widget Workaround
  • Workaround for Simple Access Control plugin not extending Text widget properly.

I've tested these and confirm that they fix the problem as I was able to reproduce. However, I'll share the requisite disclaimer that as open source software licensed under GPLv2:

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

@westonruter
7 years ago

Prevent Text widget underscore templates from being output more than once: https://github.com/xwp/wordpress-develop/pull/244/commits/6844c84

#37 @westonruter
7 years ago

  • Keywords reporter-feedback removed
  • Version changed from 4.8.1 to 4.8

#38 @westonruter
7 years ago

  • Milestone changed from 4.8.2 to 4.9

I'm going to move this to 4.9 unless it gets additional reporters noting that it needs to be released sooner.

#39 @westonruter
7 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 41245:

Widgets: Fix extensibility of Text widgets so that JS logic will initialize on subclassed widgets.

Amends [40631].
See #35243.
Fixes #41540.

Note: See TracTickets for help on using tickets.