Once you disable a text format, it is completely gone from the user interface (from the user's perspective it's as if it doesn't exist anymore).

But if you try to create a new format with the same name, you get an error:

Text format names must be unique. A format named Full HTML already exists.

Although we want to prevent people from having two enabled formats with the same human-readable name, once a format is disabled you should be able to create a new one with the same name, rather than being prevented from ever using that name again.

Fixing this takes a bit of thought due to making it work with the database schema, etc. See some of the discussion at #914458: Remove the format delete reassignment "feature", which this is a followup issue of.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Thanks for splitting, David! Definitely makes sense to tackle this separately.

Alan D.’s picture

My personal UI experience as an experienced developer hitting this for the first time. This was very perplexing, or a polite way of saying wtf?

I disabled it and it just disappeared. There were probably warnings, but I was only disabling the filter, so I ignored these.

Why? Is there a reason for this? Almost any other disable switch has a corresponding enable switch on it.

There has been a last minute API change allowed for the disable, so wouldn't the fix be as easy as creating a new enable callback and a new hook to alert modules that the change? Just my 2c

TwoD’s picture

I agree.
If I can disable something, I don't expect to be able to create something new using the same name, but I do expect to be able to enable the item using that name again.
If I remove something I don't expect it to block a new item from attempting to replace it using the same name - as I expect the first item to be gone forever.

We can't remove the item completely in this case, so why not make it possible to re-enable it?
If that's out of the question, can we instead display a list of what formats have been disabled, saying there might still be content using them? The message reported in the original post becomes much less of a WTF if the user can quickly confirm it by looking in that list.

Ideally, I'd expect an "invalidated" format to stay in such a "disabled formats"-list - perhaps with the possibility of enabling them again - until no more content is using them, then they'd be completely removed.
Of course, that would require either some sort of reference count, or another hook to ask modules if they still use a format. But then what happens to disabled, but not uninstalled, modules? Sounds like a much too complicated solution this close to D7 RCs.

Alan D.’s picture

PS: For clarification, the new hook to alert modules about the change was only intended for caching issues. This really should be done asap, so that both API changes here are introduced at about the same time.

Any tracking of formats would be a bit of a nightmare, and definitely be Drupal 8 or 9 material. Hook callbacks would pass the required info to contributed modules, but such a deep hook would not be used on the majority of cases as contributors simply would not know about it without an in depth knowledge of the core hook system.

sun’s picture

Status: Active » Needs review
FileSize
1.1 KB

This would be the simple fix. Didn't think through all possible consequences, but yeah.

Status: Needs review » Needs work

The last submitted patch, drupal.filter-format-name-unique.5.patch, failed testing.

Alan D.’s picture

Can somebody confirm that there are reasons not to simply re-enable? Is this a permissions / security issue?

Alan D.’s picture

Status: Needs work » Needs review
FileSize
8.1 KB

This is a quick hack to provide a starter for the enabled process .

Status: Needs review » Needs work

The last submitted patch, drupal-enable-format.patch, failed testing.

sun’s picture

I'm not sure whether it's still possible to fix this by introduction of an '(re-)enable' functionality. Technically, that sounds simple to do. Off the top of my head, I don't see any negative consequences. Doing so would resolve a couple of the remaining issues for D7.

sun’s picture

Priority: Normal » Major
Issue tags: +API change

Bumping this to major and tagging for a potential API change.

The notion of disabled formats had to be introduced only a few weeks ago, so sadly, it's just natural that we're facing follow-up problems now.

Roar-1’s picture

UX feedback: I just 'disabled' a text format assuming that it could be 're-enabled'. This affected all the comments on my site, and I've had to restore an older version of my site database to revert that change.

So yes, it would be great if you can re-enable ... or changed to 'delete text format' to avoid confusion.

sun’s picture

Version: 7.x-dev » 8.x-dev
Category: bug » task
Issue tags: +Needs backport to D7

Can't believe I'm doing this, but yes, this is annoying, and it's a task for D8 now. Whether it's backportable depends on the final resolution.

David_Rothstein’s picture

dddave’s picture

Walt Haas’s picture

After scratching my head over this one for a while, I used phpMyAdmin to edit the row representing the disabled filter. I changed the value of "status" from 0 to 1, and lo and behold, the disabled filter was back.

That suggests to me that it would be fairly simple to add an "enable" link to the Content authoring>Text formats page to do the same thing.

naught101’s picture

As a side-issue, it might make sense to add another flag to filter_formats:
function filter_formats($account = NULL, $include_disabled = FALSE) {

That would remove the need for the first lines in Alan's patch, while keeping the API backwards compatible.

yngens’s picture

Not funny at all, I also swallowed this bait. Now finding out there is no elegant solution to the issue going to fix manually in DB.

swentel’s picture

Status: Needs work » Needs review
FileSize
69.57 KB
9.42 KB

Here's a patch to get this rolling again. It's a bit different than Alan D. 's approach. I opted for a separate table because a disabled format shouldn't have configure options or the ability to being ordered. I've attached a screenshot of that screen with this patch. Still needs work on a couple of levels:

- UI: are 2 separate tables a good thing or not.
- If so, should we adding labels above the table or not
- Needs test, obviously. A simple enable test and also a test with a field that had a disabled format that can be seen again. Others that I might miss.

Feedback appreciated, let's get this thing fixed :)

Setting to review though to see if the bot already catches some tests errors or not (I guess it will, but was a bit lazy to run it on my local machine).

Screen Shot 2012-01-20 at 11.33.49.png

tim.plunkett’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This seems like a good candidate for tests.

+++ b/core/modules/filter/filter.admin.incundefined
@@ -60,7 +75,46 @@ function filter_admin_overview_submit($form, &$form_state) {
+        ->addTag('translatable')
+        ->fields('ff')
+        ->condition('status', 0)
+        ->orderBy('weight')
+        ->execute()
+        ->fetchAllAssoc('format');

Two space indent.

+++ b/core/modules/filter/filter.admin.incundefined
@@ -60,7 +75,46 @@ function filter_admin_overview_submit($form, &$form_state) {
+    $output = theme('table', $variables);

Why call theme('table') directly when you're returning a render array? Use '#theme' => 'table'

+++ b/core/modules/filter/filter.admin.incundefined
@@ -336,7 +390,7 @@ function filter_admin_format_form_submit($form, &$form_state) {
+ * Menu callback; confirm disabling of a format.

See http://drupal.org/node/1354#menu-callback

+++ b/core/modules/filter/filter.admin.incundefined
@@ -363,3 +417,31 @@ function filter_admin_disable_submit($form, &$form_state) {
+ * Process filter enable form submission.

See http://drupal.org/node/1354#forms

+++ b/core/modules/filter/filter.moduleundefined
@@ -132,21 +139,21 @@ function filter_menu() {
+ * Access callback for enabling or disabling text formats.

See above about callbacks

+++ b/core/modules/filter/filter.moduleundefined
@@ -132,21 +139,21 @@ function filter_menu() {
+ * Load an enabled text format object from the database.

s/Load/Loads

+++ b/core/modules/filter/filter.moduleundefined
@@ -164,6 +171,28 @@ function filter_format_load($format_id) {
+ * Load a disabled text format object from the database.

s/Load/Loads

ZenDoodles’s picture

Assigned: Unassigned » ZenDoodles
Status: Needs work » Needs review
FileSize
10 KB
4.68 KB

Re-roll based on Tim's comments. Tests and a small rework of the ui for disabled filter formats next.

ZenDoodles’s picture

D'oh... That's just wrong. See what happens when I try to do too many things at once in the middle of the night?

Fixing...

webchick’s picture

Priority: Major » Normal

I don't actually believe that this is major. There's an easy workaround which is just to call it something else.

wxman’s picture

Can the format(s) be removed manually from the database if I get desperate? If so what tables need to be searched?

Walt Haas’s picture

In Drupal 7, you can re-enable a disabled filter as follows:

1. With phpMyAdmin or the equivalent look at table filter_format. Find the row with status=0. Edit that to status=1.

2. Clear the caches (button at Administration>Configuration>Development>Performance)

3. Visit Administration>Configuration>Content authoring>Text formats. You should now see the disabled format.

wxman’s picture

Thanks that did it. Can the formats be deleted safely from the database, or is that going to cause problems?

Walt Haas’s picture

I tried the following on my Drupal 7 system:

  1. Used phpMyAdmin to delete the row 'Filtered HTML' from my filter_format table (I don't need that one, editing is done with wysiwyg_html)
  2. Went to Administration>Configuration>Development>Performance and clicked Clear all caches.
  3. Went to Administration>Configuration>Content authoring>Text formats and verified that all the other formats were still there.
  4. Went to a node and edited it successfully with each of the remaining formats.

You owe me a beer :-)

-- Walt

Alan D.’s picture

Can the formats be deleted safely from the database, or is that going to cause problems?

If they are not being used, no problems. However, if it is being used then you may get issues. Text fields with processing get run through check_markup() that will return an empty string if the format is missing.

function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) {
  if (!isset($format_id)) {
    $format_id = filter_fallback_format();
  }
  // If the requested text format does not exist, the text cannot be filtered.
  if (!$format = filter_format_load($format_id)) {
    watchdog('filter', 'Missing text format: %format.', array('%format' => $format_id), WATCHDOG_ALERT);
    return '';
  }
  ...
tim.plunkett’s picture

Status: Needs review » Needs work

CNW for tests.

eltermann’s picture

This tests expects that the creation of new text format with same machine-name and human-readable-name must both be allowed.

star-szr’s picture

Assigned: ZenDoodles » Unassigned
Status: Needs work » Needs review

Thanks @eltermann! Setting to needs review so testbot can run the test.

@eltermann - Can you please upload a combined patch as well? We usually upload two patches, in this case we should combine the test with the patch in #21 as shown in http://drupal.org/node/1468170.

eltermann’s picture

Status: Needs review » Needs work

The last submitted patch, 949220-Disabled_formats_tests-29.patch, failed testing.

star-szr’s picture

Status: Needs work » Needs review

Thanks! For future reference: Testbot looks at the last tested patch to see if it needs to update the issue status.

So if you attach the test only patch first, followed by the combined patch (still in the same comment), testbot won't set the issue to needs work and post a fail message to the issue (as in #33). Provided the combined patch passes, of course :)

aathewise’s picture

YesCT’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

looks like tests were added so removing needs tests tag.

code standards review:

+++ b/core/modules/filter/filter.admin.incundefined
@@ -11,7 +11,21 @@
+ * Form callback; Displays a list of all enabled text formats and allows them to be rearranged.

comments must wrap at 80 chars.

these one line summaries must be under 80 chars.

So more details should be added as a separate paragraph in the doc block.
http://drupal.org/node/1354#functions

(check rest of patch for same)

+++ b/core/modules/filter/filter.admin.incundefined
@@ -363,3 +418,33 @@ function filter_admin_disable_submit($form, &$form_state) {
+}
\ No newline at end of file

newline is needed.
see: http://drupal.org/coding-standards#indenting

+++ b/core/modules/filter/filter.moduleundefined
@@ -303,6 +327,26 @@ function filter_format_disable($format) {
+ * Enable a text format.

one line summary comments should start with third person verb like:
Enables ...
(check rest of patch for same)

+++ b/core/modules/filter/filter.moduleundefined
@@ -303,6 +327,26 @@ function filter_format_disable($format) {
+ * @param $format
+ *   The text format object to be enable.
+ */
+function filter_format_enable($format) {

type needs to be specified in @param
http://drupal.org/node/1354#types

Anonymous’s picture

Ran into this problem today with Drupal 7.24. I foolishly deleted Filtered HTML text format. Tried to re-create and of course the machine name was in use.

Thanks to #16 and this link, I used phpMyAdmin to edit my database. Obviously this is not a viable solution for many people and we really need a backport of any solution to D7.

http://stackoverflow.com/questions/9883883/re-enabling-disable-full-html...

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 32: 949220-Disabled_Formats-20.patch, failed testing.

cilefen’s picture

Issue summary: View changes

Should we postpone this on #2502637: Disabled text formats can't be seen in the GUI?

I am all for displaying the disabled formats the way we do with Views.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

welly’s picture

I've been working on a patch for this as I find this problem rather infuriating. It still needs work (and tests) but the basics are there! Happy to backport this to D7 once I've finished with D8.

cilefen’s picture

jibran’s picture

Thanks @welly for the patch. Here are some points.

  1. +++ b/core/modules/filter/src/Entity/FilterFormat.php
    @@ -20,7 +20,7 @@
    - *       "disable" = "Drupal\filter\Form\FilterDisableForm"
    + *       "disable" = "Drupal\filter\Form\FilterDisableForm",
    

    Shouldn't we add enable here as well?

  2. +++ b/core/modules/filter/src/Entity/FilterFormat.php
    @@ -193,6 +194,19 @@ public function disable() {
    +
    +    parent::enable();
    +
    +    // Clear the filter cache whenever a text format is enabled.
    +    filter_formats_reset();
    +
    +    return $this;
    

    No need for extra new lines.

welly’s picture

Thanks for the review, jibran!

Point 1. I'm not submitting a form to enable the filter format - I'm just using a text link that calls FilterController::enableFilter() to enable the filter. It didn't make sense that a confirmation form needed submitting to enable the format as it's not a destructive call.

Point 2. Haven't touched FilterFormat::disable() :) See: https://api.drupal.org/api/drupal/core%21modules%21filter%21src%21Entity... to compare.

I've noticed that disabled text formats still have the Configure link in the operations drop down and that needs removing when a text format is disabled as it returns a 404. Will fix that up next.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Title: Impossible to create a new text format with the same name as a disabled one » Allow disabled text formats to be re-enabled
Category: Task » Feature request

Updating issue title to match the patch.

David_Rothstein’s picture

Title: Allow disabled text formats to be re-enabled » Text format names can never be reused (Possible solution: Allow disabled text formats to be re-enabled)
Category: Feature request » Bug report
Issue tags: +Needs issue summary update

It's still a bug, regardless of the proposed solution.

I'm not a big fan of that solution because it means there's no way to remove an unused text format from the admin UI. (If it were coupled with a way to delete text formats also, it would be a good solution - but that's a whole other can of worms.)

Unfortunately, though, it is hard to think of too many other ways to fix this. When this issue was originally filed it was about human-readable names only (which would have been easy to address) but shortly thereafter formats got machine-readable names too, which makes this much more difficult because unlike human-readable names you absolutely can't let machine names duplicate each other.

Maybe the disabled text formats should be listed on a separate page so they are at least out of the way?

David_Rothstein’s picture

Note: The latest patch (in #43) seems to be missing a lot of things that were in the earlier patches.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dqd’s picture

Version: 8.4.x-dev » 8.5.x-dev
Priority: Normal » Major

from #3

If I can disable something, I don't expect to be able to create something new using the same name, but I do expect to be able to enable the item using that name again.

Since this happend already multipe times for many users with default (standart) text fomatting settings disabled temporary and disappearing forever while they where awaiting to be able to reenable them and this can cause a lot of mess with already created content, I really really would ask for setting this long term issue to major before it turns into a Drupal #WTF.

@webchick:

I don't actually believe that this is major. There's an easy workaround which is just to call it something else.

While agree with you to rather de-escalate issue queues often being too much knocking for their level of priority, I maybe have a conclusive argument to bring up here: There are modules providing text formats, like the php module and the script filter module does, and others. Having a one way ticket like it is at the moment regarding creating and "disabling" formats forever in the GUI, it will most likely make it unpossible to install such modules if it collides with disabled formats, will it make inpossible to uninstall and reinstall such modules too. Especially if the module uninstallation requires to disable the format, like the php module does. It also will create conflicts with older maybe forgotten formats with same names turning the installation of such modules into a possible mess I can't oversee yet. Additionally we can see how the few attention of this issue turned it down a lil bit lately and we definitely need to get rid off it. Would you agree with me on this?

And since 8.4 is out we maybe need to set it to 8.5.

dqd’s picture

Oh sorry, I didn't saw your post @cilefen

I prefer #2502637-63: Disabled text formats can't be seen in the GUI

But since this issue here is older and we actually follow the rule to keep the older and set the newer to duplicate, we should consider to merge both attempts somehow. I agree with you on the "what should be fixed" priority in the newer one. So could we woop this all over here? I set it to "related"...

dqd’s picture

@David_Rothstein

Maybe the disabled text formats should be listed on a separate page so they are at least out of the way?

I was intuitively thinking the same like @cilefen on this @ #40 when I was hitting this issue first ime:

I am all for displaying the disabled formats the way we do with Views.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

MartinMa’s picture

There is just another problem: I get a lot of messages in dblog if I "disable" a text format:
Filter 21.07.2019 - 13:28 Disabled text format: basic_html.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pameeela’s picture

Status: Needs work » Closed (duplicate)
Issue tags: +Bug Smash Initiative

I know that typically the newer issue should be closed as a duplicate but in this case there is much more recent work in #2502637: Disabled text formats can't be seen in the GUI so I'm closing this one instead. I've moved credit from here to that issue also. Hopefully we can progress the other issue now.