Clean Install (drupal 6.19) added WYSIWIG module and when configuring the client side editors and added Ckeditor to Filtered Input I get this error

user warning: Duplicate entry '2' for key 'PRIMARY' query: INSERT INTO wysiwyg (format, editor) VALUES (2, '') in /web/sites/all/modules/wysiwyg/wysiwyg.admin.inc on line 493.

Everything functions fine even though the error occurs, and the error does not show again.

CommentFileSizeAuthor
#12 wysiwyg.940312.12.patch642 bytestwod

Comments

twod’s picture

Sounds like it tried to create an editor profile twice. Did you by any chance double-click the submit button when saving the settings (I'm assuming this is when it happened)?

twod’s picture

Status: Active » Postponed (maintainer needs more info)

Can you reproduce this on another clean installation?

seaslug’s picture

Component: Editor - CKeditor » Code

yip i don't often do a clean install but every time i have it has done it, again before i posted the first time, i did a clean install and received this error, as i said it does not stop anything from working, just raised it as a minor bug.

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Sorry, I just did the same and didn't get the error. Without further information this issue can only be closed as not reproducible.

Feel free to re-open this issue if you want to provide further information. Thanks.

dharmanerd’s picture

Version: 6.x-2.1 » 6.x-2.2

This was a problem for me too! Aquia Drupal 6.22 w/ wysiwyg 6.x-2.4. So far it's only happened once (w/ two error messages) on the first attempt to configure ckeditor.

Duplicate entry '3' for key 'PRIMARY' query: INSERT INTO wysiwyg (format, editor) VALUES (3, '') in /var/www/vhosts/artjewelryforum.org/httpdocs/sites/all/modules/wysiwyg/wysiwyg.admin.inc on line 509.

Duplicate entry '1' for key 'PRIMARY' query: INSERT INTO wysiwyg (format, editor) VALUES (1, '') in /var/www/vhosts/artjewelryforum.org/httpdocs/sites/all/modules/wysiwyg/wysiwyg.admin.inc on line 509.

karol haltenberger’s picture

Version: 6.x-2.2 » 6.x-2.4
Status: Closed (cannot reproduce) » Needs review

This error - although not serious - is still present in 2.4 and is caused by the following:

When an editor is NOT selected for an input format, the $form_state['values']['formats'] array contains its entry with an empty value.
On line 508 this generates the query string "UPDATE wysiwyg SET editor = '' WHERE format = 1" (supposing the format'S id is 1).
If the format had no editor selected before, therefore its entry in the database is empty (''), MySQL will NOT update and the reported number of affected rows is 0.
This triggers line 510 which tries to insert the row, hence the error.

Quickfix:
wysiwyg.admin.inc, line 509:

if (!db_affected_rows()) {

replace with

if (!db_affected_rows() && $values['editor']) {

Or maybe the whole update/insert section (lines 508-511) should be put in an if($values['editor'])){} block

twod’s picture

Status: Needs review » Active

Thanks for the info and debugging work.
I don't have time to confirm this now but if someone does it'd be greatly appreciated.

chichilatte’s picture

I'm getting the same warning. D-6.22, Wysiwyg-6.x-2.4. I have 3 input formats, with the third (PHP code) having no editor selected.
user warning: Duplicate entry '3' for key 'PRIMARY' query: INSERT INTO wysiwyg (format, editor) VALUES (3, '') in /Users/Shared/projects/myproject/svn/published/sites/all/modules/wysiwyg/wysiwyg.admin.inc on line 509.

(I tried giving the 'PHP code' input format an editor and the problem disappeared. However, there doesn't seem to be a way to undo the change! Ha!)

Not a showstopper, this bug, but looks a bit scary :)

twod’s picture

It looks a bit scary but it's nothing to worry about. For some odd reason, it's trying to recreate a "no editor for this format"-record.

If you've assigned an editor profile to a format and don't need it anymore, just click remove/delete in the right column. It won't touch your formats, just the editor profile.

dagomar’s picture

I got this error too. It's no biggie, it will only show up on admin pages, right?

spgd01’s picture

I still get the error

twod’s picture

Status: Active » Needs review
StatusFileSize
new642 bytes

I made a patch of Ypthor's change in #6. Could you please try it?

If I've understood it correctly, this only happens on D6, so the patch is for 6.x-2.x.

carwin’s picture

Status: Needs review » Reviewed & tested by the community

Patch applied cleanly, no errors in a clean environment.

Steps to produce error

  • Install Drupal
  • Install WYSIWYG
  • Apply Patch
  • Download CKEditor
  • Apply CKEditor to Filtered HTML text format while leaving Full HTML set to "No Editor"
  • No Errors, tried combinations of applying to both Full and Filtered and then just to Full.
summit’s picture

Hi, working for me also.
Will this patch be committed please?
greetings, Martijn

twod’s picture

Status: Reviewed & tested by the community » Fixed

I committed the patch from #12 to the 6.x-2.x and 5.x-2.x branches and credited Ypthor for finding the cause.
Development snapshots will be updated within 12hrs and the fix will be part of the next releases.

Thank you all for reporting, debugging and reviewing!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.