Delete corrupt data in database from a "broken photo"
I had a similar Error (ERROR_MISSING_OBJECT) but non of the above post was a solution for me.
(ERROR_MISSING_OBJECT)in
modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 167 (GalleryCoreApi::error)
modules/core/classes/GalleryStorage.class at line 313 (GalleryStorageExtras::loadEntities)
modules/core/classes/helpers/GalleryEntityHelper_simple.class <b>at line</b> 71 (GalleryStorage::loadEntities)
modules/core/classes/GalleryCoreApi.class at line 2361 (GalleryEntityHelper_simple::loadEntitiesById)
modules/core/classes/GalleryView.class at line 356 (GalleryCoreApi::loadEntitiesById) modules/core/ShowItem.inc at line 106 (GalleryView::getItem)
modules/core/ShowItem.inc at line 61 (ShowItemView::getItem)
modules/core/classes/GalleryView.class at line 293 (ShowItemView::loadTemplate)
main.php at line 465 (GalleryView::doLoadTemplate)
main.php at line 104
main.php at line 88
Request variables: Array [path] => SOME_ALBUM_2009/SOME_PHOTO.JPG.html\n [itemId] => 12345
[view] => core.ShowItemThe effect was that one broken picture (damaged data in mysql database) was the source of the problem that resulted in the error while the page where the broken image was on crashed. This happened with the normal album view and also with dynamic album view. Like:
New Photos : /index.php?q=gallery&g2_view=dynamicalbum.UpdatesAlbum
Most viewed Photos : /index.php?q=gallery&g2_view=dynamicalbum.PopularAlbum
Random Photos : /index.php?q=gallery&g2_view=dynamicalbum.PopularAlbum
The effect was that I could view any page except the one with the broken image on it. I had a small album with 5 pages and the broke image was on page 4. I could not view page 4. All other pager where OK.
I searched more than a day in my database for the problem. I couldn't find it.
I checked all tables that valiant named and all others:
g2_Entity,
g2_ChildEntity,
g2_FileSystemEntity,
g2_Item,
g2_DataItem,
g2_PhotoItem
I checked the integrity of the record by compare the complete record from the broken g_id with a the first good g_id before the broken g_id. I didn't find any different that could cause the problem.
This was my solution that SOLVED my problem.
Step 1
Find out with Photo causes the problem.
I did that by changing the layout of the album:
- Go to the album with the problem.
- Edit Album
- Tab Theme
- change 12 (or whatever) pictures per row to 1
- and change 3 (or whatever) pictures per colum to 1
- Click Save These Setting
Now every picture has his one page. By stepping trough the pages I finally got the broken Photo. In my case is was photo SOME_PHOTO.JPG
Step 2
Find the g_id from the album
In the MYSQL databse you can find the g_id of this picture in table g2_FileSystemEntity.
Please notice that it's possible that a photo with name SOME_PHOTO.JPG is used more than once. You can use the same filename in every album again. So the correct SOME_PHOTO.JPG is the first one under a record that has the album name (album path name or path name on filesystem) in column g_pathComponent. You can find this by getting the album path name in the frond end from gallery:
- go to the album with the problem
-> Edit Album
-> tab General. The first field in the album path name (ALBUM_PATH_NAME)
Now execute this query in your MYSQL Client:
SELECT g_id FROM g2_FileSystemEntity WHERE g_pathComponent = 'ALBUM_PATH_NAME';Suppose the album ALBUM_PATH_NAME is SOME_ALBUM_2009 than the query looks like this:
SELECT g_id FROM g2_FileSystemEntity WHERE g_pathComponent = 'SOME_ALBUM_2009';This query gives you one line with one value. This is the g_id of the album. ALBUM_G_ID
Step 3
Find the g_id from the photo
Now execute this query:
SELECT * FROM g2_FileSystemEntity WHERE g_id >= ALBUM_G_ID AND g_pathComponent = 'SOME_PHOTO.JPG'We suppose the found g_id is 12345 the the query look like this:
SELECT * FROM g2_FileSystemEntity WHERE g_id >= 123456 AND g_pathComponent = 'SOME_PHOTO.JPG'Now you got the g_id of the broken picture.
Suppose the photo g_id = 12380
Step 4
Delete the broken photo
Because every method of displaying the broken image end up in a crash I could not delete the photo using the Gallery2 Front end.
To delete the image I made a index.html file on my desktop with a form to delete the broken photo.
First visit the album with the front end, login and get a cookie.
Select Delete Items from the menu
IMPORTANT: NOT FROM THE SELECT-LIST UNDER THE PHOTO !!!
Open the source from that page and copy the following lines to the index.html file on your desktop.
Where:
- The domain name example.com has to be substituted by you domain name
- The value of g2_authToken has a other value than printer here.
- The value of g2_itemId has to be changed to the value of your album (ALBUM_G_ID in our example or 12345)
- The id and the name of the checkbox must be changed to the g_id from the broken photo (12380 in this example)
The HTML file looks like this:
<form action="http://www.example.com/gallery2/main.php" method="post" enctype="application/x-www-form-urlencoded" id="itemAdminForm">
<input type="hidden" name="g2_return" value="http://www.example.com/gallery2/gallery/v/zeilen/mannenweekend_juli_2009/?g2_page=5"/>
<input type="hidden" name="g2_formUrl" value="http://www.example.com/gallery2/main.php?g2_view=core.ItemAdmin&g2_subView=core.ItemDelete&g2_itemId=85372&g2_anchorId=86470"/>
<input type="hidden" name="g2_authToken" value="6ef99825c278"/>
<input type="hidden" name="g2_controller" value="core.ItemDelete"/>
<input type="hidden" name="g2_form[formName]" value="ItemDelete"/>
<input type="hidden" name="g2_itemId" value="12345"/>
<input type="checkbox" id="cb_12380" name="g2_form[selectedIds][12380]"/>
<input type="submit" class="inputTypeSubmit" name="g2_form[action][delete]" value="Delete"/>
</form>- Save the file on your desktop
- Open it with a browser.
- Check the checkbox
- Click on delete
Now the broken image (destructed data) is deleted.
You can upload the image again if you like. The problem in/was not in the image itself but somewhere in the database. Don't forget to change the album properties rows and columns to the correct values (you changed them in step 1).
