3.0.1: show=xxx links from deleted photos cause HTTP 500 and SQL Errors

MarkRH

Joined: 2007-05-25
Posts: 241
Posted: Sat, 2011-02-05 20:44

Since the search bots like to index everything if you let them.. If they grab a show=xxx link which normally causes an album page to appear that contains that photo and you later delete that photo, well, the Gallery barfs. :) It causes an HTTP 500 error and an SQL error:

Database_Exception [ Database Error ]: #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NULL' at line 3 [ SELECT COUNT(*) AS `records_found` FROM `g3_items` WHERE `parent_id` = NULL AND IS NULL ] 

The code needs to be changed to handle deleted photos and throw a 404 not found page instead.

Hmmm.. the positive side to this, I think I can find the section of code that figures out the album page now based on the error trace.

Thanks,
Mark H.

Using Gallery 3.0.1 - gallery.markheadrick.com

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-02-06 00:15

So we should keep track of deleted items?
How do we differentiate between a not found ( some random item name ) and a deleted item?

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
danneh3826
danneh3826's picture

Joined: 2007-08-18
Posts: 290
Posted: Sun, 2011-02-06 14:51

i kinda +1 this. maybe a flag could be set against the item to indicate "deleted" status. it's not like that item id is ever going to be used again.
or, the item controller could just return a 404 whenever it can't find an item. from a google indexing point of view, webmaster tools prefers you return a 404 rather than a 500, however, maybe a module could be written at some point to do what ecommerce sites and the likes do - if you attempt to get to a url for a product that no longer exists, it takes you to another page (returns a 200 status), and that page lists "alternatives", perhaps photos with tags for what that item previously had, or something.

$0.02 :)

Dan

danneh.org :: Gallery3

 
MarkRH

Joined: 2007-05-25
Posts: 241
Posted: Sun, 2011-02-06 20:41

Ok, to further explain. Here's two links that were once valid that Google had indexed:

h t t p : / / gallery.mysstie.com/eq2/self-portraits/mintee/?show=101

and

h t t p : / /gallery.mysstie.com/photos/101

This particular photo has since been deleted. The first link causes an HTTP 500 error and Kohana dying with a SQL error. I guess because it can't figure out what album it was a part of and is executing a SQL statement containing NULL values, resulting in a MySQL error.

The 2nd link causes a 404 Not Found and causes the standard Not Found page, as it should.

Hmmm.. I might tell Google to ignore the show=xxx links because it's really just duplicates of existing album pages. I've already disallowed it from indexing /photos/ in robots.txt

Thanks,
Mark H.

Using Gallery 3.0.1 - gallery.markheadrick.com