Comments Problem when user is deleted

blkphtm

Joined: 2005-10-18
Posts: 6
Posted: Thu, 2005-10-20 13:38

I am running into a problem with the comments. I have the system setup so registered users can add/view comments. If a user posts comments to a picture, then the user is deleted later, any comments will not show up for that picture. On the main page, it still shows that there are X number of comments for that picture. Even if you login in as the admin, you cannot view, edit, or delete the comments. The comments are still in the comments table in the database though.

How can I fix this?

Daren

Gallery version = 2.0.1 core 1.0.0.1
PHP version = 4.4.0 cgi-fcgi
Webserver = Microsoft-IIS/5.0
Database = mysql 4.1.14-nt
Toolkits = Gd
Operating system = Windows NT SERVER03 5.0 build 2195
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; InfoPath.1)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2005-10-20 13:48

You've look at the database with phpMyAdmin or something to verify the comment still exists?

Have you tried clearing your db cache? Site Admin > Maintenance

I'd think that deleting a user should delete their comments. But I haven't tried it yet.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
blkphtm

Joined: 2005-10-18
Posts: 6
Posted: Thu, 2005-10-20 13:59

I have looked at the database tables and the comments are deleted for that user.

But any other user that has posted a comment to the same picture that the deleted user did don't show up in the picture page. The comments are still actually in the table though. If you add a comment, the data will be in the table, but still will not show the comments on the page.

I have ran all the delete cache options in the Maintenance section and still having no luck.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Fri, 2005-10-21 13:22

Doesn't sound good. Can't believe this hasn't been discovered yet. Could be a bug. I won't have time to try and duplicate until this weekend, but I'll see if I or one of the devs can duplicate it.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-10-21 15:36

you say we don't delete comments of user x if user x is deleted?

we should of course.
nivekiam, let me know if you can reproduce that.

also, please look at the following scenario:

user x has an item. user y adds comments to the item of user x.
now we delete user x.
the comments of user y about item x should also be deleted.

what we already do (you don;t have to check this, we've got unit tests that cover this):
in our user deletion code we already take care of such scenarios if it's about albums and items.
e.g. user x has an album, user y adds an item to the album of user x. now we delete user x and user y item is also deleted (or we reassign the album to admin and user y's item is preserved) and / or we delete all items / subalbums of user x and reassign the albums of x that have sub items of other users to an admin user.

what i don;t remember is whether we handle GalleryEntities in general or only GalleryDataItem vs GalleryAlbum item. so it *could* be that we have to change the code to handle also comments etc.

 
blkphtm

Joined: 2005-10-18
Posts: 6
Posted: Fri, 2005-10-21 16:01
valiant wrote:
you say we don't delete comments of user x if user x is deleted?

we should of course.

That part works.

User X, Y, and Z posts comments to the same picture. Then user Y gets deleted. No comments show up for any picture that user Y has commented to. The comments from user X and Z are not showing up for any picture that user Y had commented on. The actual comments for user X and Z are still in the comments table, comments from user Y are gone.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2005-10-23 14:57

So far here is what I've tested (photo = item):

--photo added by admin
--user1 then user2 add comments to photo
--photo gets deleted, all comments are deleted from database

--photo added by admin
--user1 then user2 add comments to photo
--user1 is deleted.
*user1's comments are not deleted from database and now no comments will show up on that page
*looking at the source of the page, the Show Comments block doesn't even show up
*also, the thumbnail on the album page show there are still 2 comments for that photo
*able to add comments and they show up in the DB, but still don't show up on the page
*manually deleted that comment from the database fixes the problem of comment not showing and fixes the comment count for that item.

--photo added by user2
--user3 adds comment to photo
--user2 is deleted selecting the option to delete all items user2 created
*BAD, the items are not deleted, but the Site Admin takes over ownership....
*and any comments made by user2 are also not deleted.

--photo is assigned ownership to user3 by admin
--user3 adds another new photo, now user3 "owns" 2 photos
--user3 is deleted, again using option to delete all items owned by user3
*only the one the first photo assigned ownership to user3 by the admin was deleted (and that photos's comments were deleted)
*the photo user3 added was not deleted and it's ownership was changed to Site Admin

valiant, is there anything I missed or anything else that needs to be tested. Looks like there are a couple of bugs there. I'm currently running version 1.0.5 out of CVS, updated 7:30am PST 2005-10-23

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-10-23 15:04

thanks a lot!

please file a bug report on http://sf.net/projects/gallery/
then we can start by writing new unit tests to cover these scenarios and then fix the problem.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2005-10-23 15:14

Will do! I'll get to that tonight, busy day :)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-10-25 13:05

Done and done
User comment bug:
https://sourceforge.net/tracker/index.php?func=detail&aid=1337420&group_id=7130&atid=107130

Delete user and items don't delete bug:
https://sourceforge.net/tracker/index.php?func=detail&aid=1337426&group_id=7130&atid=107130
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
ActiveNight

Joined: 2005-07-10
Posts: 71
Posted: Sat, 2005-10-29 00:38

I have exactly the same error..is there any solution? You can watch it for example on http://www.ms-chat.com/embedGallery.php?g2_view=core.ShowItem&g2_itemId=15578

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-10-29 02:23

it isn't fixed yet, no.

 
ActiveNight

Joined: 2005-07-10
Posts: 71
Posted: Wed, 2005-11-09 22:06

At sourceforge there you can see, that it is fixed... I re-installed the comment-module, but the comments are still invisible. What means "listening to userEnttity delete events" at https://sourceforge.net/tracker/index.php?func=detail&aid=1337420&group_id=7130&atid=107130 ???

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-11-10 00:42

well, i fixed it in cvs. that means i fixed the bug. it won't fix your broken installations.

to fix your g2 you may have to manipulate your db manually.

select g_id from g2_Comment where ownerId not in (select distinct g_id from g2_User);

with the resulting ids, do the following:
- delete them from g2_Comment
- delete them from g2_ChildEntity
- delete them from g2_Entity

 
ActiveNight

Joined: 2005-07-10
Posts: 71
Posted: Sun, 2005-11-13 13:44

how can i find out which g_id i have to select? I have over 10.000 registered users...and I can't see the comments. In only know the ids of the photos...
When i re-installed the comment-module... is it possible that this error occured a again?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-11-13 15:02

when you uninstall the comments module, all comments will be deleted / lost!

to find out which comments need to be changed:

SELECT DISTINCT c.g_id
FROM g2_Comment c left join g2_User u
ON c.g_commenterId = u.g_id AND u.g_id is NULL;

it will result the comment g_id that need to be updated. you can then fix these comments with:
(i assume the above query returned 4 numbers: 256, 84, 23345, 125)
Update g2_Comment Set g_commenterId = 5 WHERE g_id IN (256, 84, 23345, 125);

5 is the guest user. so you will reassign all these comments to the guest user.
the numbers 256, 84, 23345, 125 are just an example. the numbers you will have to enter are different. you need to enter the numbers that were returned in the first query.

 
blkphtm

Joined: 2005-10-18
Posts: 6
Posted: Mon, 2005-11-14 16:30

I downloaded the Gallery files from the CVS server and replaced them on top of my exsisting installation, then ran the upgrader and everything works fine now.