I have the g2_data directory contents but not the database contents - Is there a tool that will add the missing rows from my database by crawling through the contents of the cache/entity directory?
Reason....
I backed-up my database and then upgraded my NSA310 firmware. This installed Gallery3 which did not work (including many other features on my device). So, I restored the previous version of the firmware and installed Gallery2 again. I restored the g2_data directory but found that the backup that I had made has been overwritten. I have an old backup of the database but it is quite out of date - I restored this and it work with only half of my pictures.
I don't want to re-import the directory structure again because I will loose all my links to the gallery object that I have from my web-site (because the links are all using the itemId <img class="g2image_normal alignleft" title="Panarama03" src="http://drovercottage.servebeer.com/pkg/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=4196&g2_GALLERYSID=ec2cf8f61a2910d29dbc2120e0bcd1b9" alt="Panarama03" width="300" height="96">)
I have found that the cache/entity directory contains data that might be used to re-build the database.
Is there a tool to do this?
Posts: 8339
no.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 3
It looks as though I'll have to write one myself then. It will probably be cobbled together with a bunch of shell and awk scripts to generate a file of SQL insert statements that do the biz. Thanks for a quick response!
Posts: 8339
My importXML.php script crawls your gallery and compares filename and filesize to that of a gallery xml backup and will import the title, description, summary...
BUT that does not help you retain old links.
As items are added to gallery they receive an ID.
And as derivatives (thumbs, resizes..) are built they also receive an ID.
You would have to add everything back in the same sequence and have derivatives built at the same moment as last time to maintain your links.
It would be far far easier just to update the old links to the new corresponding ones.
You could restore your older DB backup and just re-add any newer items. May reduce the task of updating your links.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 3
Thanks again. You may be right that I should simply re-import and then update all my links to the gallery but I have loads of them both in my website and also in Google-Earth KML documents. So I looked at the Gallery Database Schema and drew this.
[img]http://drovercottage.servebeer.com/MyWeb/Web/Gallery2_schema.gif[/img]
and then I looked at the *.inc files in the cache/entity directories and found that the structure described most attributes and their values like this:
modules/core/classes/GalleryPhotoItem.class|O:16:"GalleryPhotoItem":25:{
s:5:"width";i:3888;
s:6:"height";i:2592;
s:8:"mimeType";s:10:"image/jpeg";
s:4:"size";i:3238630;
s:18:"canContainChildren";i:0;
s:11:"description";s:0:"";
s:8:"keywords";N;
s:7:"ownerId";i:6;
s:8:"renderer";N;
s:7:"summary";s:0:"";
s:5:"title";s:8:"IMG_0071";
s:20:"viewedSinceTimestamp";i:1326202172;
s:20:"originationTimestamp";i:1278401769;
s:13:"pathComponent";s:12:"IMG_0071.jpg";
s:8:"parentId";i:100;
s:2:"id";i:108;
s:17:"creationTimestamp";i:1326202172;
s:10:"isLinkable";i:1;
s:6:"linkId";N;
s:12:"linkedEntity";N;
s:21:"modificationTimestamp";i:1326202172;
s:12:"serialNumber";i:1;
s:10:"entityType";s:16:"GalleryPhotoItem";
s:14:"onLoadHandlers";N;
s:17:"_persistentStatus";
These show the itemId and the parentId and so I can insert this data into the schema above and retain my links. At the end, I simply select MAX(g_id)+1 from g2_entity and insert that into g2_sequenceId.
Well....that's the theory anyway - I'll make sure that I have a backup first!
I noticed that there were a number of people in the forum who were looking for a database schema diagram. The only schema diagrams that seem to be documented are the class structures