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.
Comment | File | Size | Author |
---|---|---|---|
#43 | 949220-enable-disabled-formats.patch | 5.31 KB | welly |
#32 | 949220-Disabled_Formats-20.patch | 10 KB | eltermann |
#32 | 949220-Disabled_formats_tests-29.patch | 1.19 KB | eltermann |
#30 | 949220-Disabled_formats_tests-29.patch | 1.19 KB | eltermann |
#21 | interdiff.txt | 4.68 KB | ZenDoodles |
Comments
Comment #1
sunThanks for splitting, David! Definitely makes sense to tackle this separately.
Comment #2
Alan D. CreditAttribution: Alan D. commentedMy 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
Comment #3
TwoDI 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.
Comment #4
Alan D. CreditAttribution: Alan D. commentedPS: 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.
Comment #5
sunThis would be the simple fix. Didn't think through all possible consequences, but yeah.
Comment #7
Alan D. CreditAttribution: Alan D. commentedCan somebody confirm that there are reasons not to simply re-enable? Is this a permissions / security issue?
Comment #8
Alan D. CreditAttribution: Alan D. commentedThis is a quick hack to provide a starter for the enabled process .
Comment #10
sunI'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.
Comment #11
sunBumping 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.
Comment #12
Roar-1 CreditAttribution: Roar-1 commentedUX 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.
Comment #13
sunCan'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.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedPartially related issue: #1197814: Change terminology from "disable" to "delete" when disabling a text format
Comment #15
dddave CreditAttribution: dddave commentedmarked #1216318: Users can delete default text formats but they cannot be restored as dupe.
Comment #16
Walt Haas CreditAttribution: Walt Haas commentedAfter 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.
Comment #17
naught101 CreditAttribution: naught101 commentedAs 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.
Comment #18
yngens CreditAttribution: yngens commentedNot 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.
Comment #19
swentel CreditAttribution: swentel commentedHere'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).
Comment #20
tim.plunkettThis seems like a good candidate for tests.
Two space indent.
Why call theme('table') directly when you're returning a render array? Use
'#theme' => 'table'
See http://drupal.org/node/1354#menu-callback
See http://drupal.org/node/1354#forms
See above about callbacks
s/Load/Loads
s/Load/Loads
Comment #21
ZenDoodles CreditAttribution: ZenDoodles commentedRe-roll based on Tim's comments. Tests and a small rework of the ui for disabled filter formats next.
Comment #22
ZenDoodles CreditAttribution: ZenDoodles commentedD'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...
Comment #23
webchickI don't actually believe that this is major. There's an easy workaround which is just to call it something else.
Comment #24
wxman CreditAttribution: wxman commentedCan the format(s) be removed manually from the database if I get desperate? If so what tables need to be searched?
Comment #25
Walt Haas CreditAttribution: Walt Haas commentedIn 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.
Comment #26
wxman CreditAttribution: wxman commentedThanks that did it. Can the formats be deleted safely from the database, or is that going to cause problems?
Comment #27
Walt Haas CreditAttribution: Walt Haas commentedI tried the following on my Drupal 7 system:
You owe me a beer :-)
-- Walt
Comment #28
Alan D. CreditAttribution: Alan D. commentedIf 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.
Comment #29
tim.plunkettCNW for tests.
Comment #30
eltermann CreditAttribution: eltermann commentedThis tests expects that the creation of new text format with same machine-name and human-readable-name must both be allowed.
Comment #31
star-szrThanks @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.
Comment #32
eltermann CreditAttribution: eltermann commentedsure
Comment #34
star-szrThanks! 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 :)
Comment #35
aathewise CreditAttribution: aathewise commentedComment #36
YesCT CreditAttribution: YesCT commentedlooks like tests were added so removing needs tests tag.
code standards review:
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)
newline is needed.
see: http://drupal.org/coding-standards#indenting
one line summary comments should start with third person verb like:
Enables ...
(check rest of patch for same)
type needs to be specified in @param
http://drupal.org/node/1354#types
Comment #37
Anonymous (not verified) CreditAttribution: Anonymous commentedRan 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...
Comment #40
cilefen CreditAttribution: cilefen commentedShould 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.
Comment #43
welly CreditAttribution: welly at PreviousNext commentedI'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.
Comment #44
cilefen CreditAttribution: cilefen commentedI prefer #2502637-63: Disabled text formats can't be seen in the GUI.
Comment #45
jibranThanks @welly for the patch. Here are some points.
Shouldn't we add enable here as well?
No need for extra new lines.
Comment #46
welly CreditAttribution: welly at PreviousNext commentedThanks 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.
Comment #48
Wim LeersUpdating issue title to match the patch.
Comment #49
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedIt'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?
Comment #50
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedNote: The latest patch (in #43) seems to be missing a lot of things that were in the earlier patches.
Comment #52
dqdfrom #3
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:
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.
Comment #53
dqdOh sorry, I didn't saw your post @cilefen
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"...
Comment #54
dqd@David_Rothstein
I was intuitively thinking the same like @cilefen on this @ #40 when I was hitting this issue first ime:
Comment #58
MartinMa CreditAttribution: MartinMa commentedThere 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.
Comment #63
pameeela CreditAttribution: pameeela commentedI 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.