To reproduce: 'Configure' the Filtered HTML format, set the name to Full HTML.
Relevant error: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Full HTML'' for key 'name': UPDATE {filter_format} SET name=:db_update_placeholder_0, cache=:db_update_placeholder_1 WHERE (format = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => Another Format [:db_update_placeholder_1] => 1 [:db_condition_placeholder_0] => 5 ) in drupal_write_record() (line 6201 of includes/common.inc).
Reason: filter_admin_format_form_validate() only validates new formats, not changes to existing ones.

CommentFileSizeAuthor
#1 drupal-filter-899752-1.patch1.41 KBtim.plunkett

Comments

tim.plunkett’s picture

Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new1.41 KB

This 'works'. I have a feeling its not the way to do it, would love to learn the right way.

Status: Needs review » Needs work

The last submitted patch, drupal-filter-899752-1.patch, failed testing.

tim.plunkett’s picture

Well duh, should've seen that coming. Leaving as needs work, maybe I'll have more time for this later.

sun’s picture

To do this, you need to add an internal (#type = 'value') form element called "old_name" to the form, so as to be able to recognize whether the text format name actually changed.

sun’s picture

Priority: Major » Normal

Not major, just a bug.

sun’s picture

I was wrong in #4. The "old name", if any, can be read from $form['name']['#default_value']

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.