Steps to reproduce:
1) Create a new domain record
2) Assign a user to that domain on the user's profile page
3) Delete the domain record

Expected result:
"Domain status" group on user's profile page only has bullets for existing domains that the user is assigned to. The domain_editor row for that user and the deleted domain doesn't exist anymore.

Actual result:
"Domain status" group has one more bullet without text. The domain_editor row still exists.

Proposed solution:
Delete the domain_editor database entries for a domain when that domain is deleted.

CommentFileSizeAuthor
#2 domain-378258-2.patch1.52 KBsvdoord

Comments

svdoord’s picture

Oh, by the way, I think a fix to this issue should include an upgrade script that cleans up the domain_editor table by removing all rows for which the corresponding domain doesn't exist anymore.

I'll see if I can roll out a patch, but I don't know yet how such upgrade scripts are created.

svdoord’s picture

Status: Active » Needs review
StatusFileSize
new1.52 KB

Ok, here's a patch for my issue. It adds a DELETE query for domain_editor when a domain is deleted, and it adds a database update function to domain.install.

Please review and hopefully add it to the next release candidate!

agentrickard’s picture

Status: Needs review » Needs work

Is WHERE NOT EXISTS postgres compliant syntax? I don't think it is. We need an ANSI-standard query here.

We try to avoid subselects, too.

The other part of the patch is a nice catch, committed that part.

svdoord’s picture

It should work in PostgreSQL just fine. According to this thread (http://codingforums.com/showthread.php?p=780895), it has been in the ANSI SQL standard since 1985. I will test this to make sure; I'm installing PostgreSQL as we speak.

Two questions:
- Why do you try to avoid subselects?
- What would you prefer instead? A loop over the result set of a select, and then a delete for each entry?

svdoord’s picture

Just verified that the WHERE NOT EXISTS construct works in PostgreSQL 8.3, but again: it is plain ANSI SQL as far as I know. I've used it for many, many years.

agentrickard’s picture

Subselects can be resource intensive, and require MySQL 4.1 >, which is required for D6, so I suppose it does not matter. A loop is the other option.

WHERE NOT EXISTS is fine.

agentrickard’s picture

Status: Needs work » Patch (to be ported)

Tested and committed. Thanks!

svdoord’s picture

And thanks to you for following up on this so quickly!

agentrickard’s picture

Status: Patch (to be ported) » Closed (fixed)