keywords missing when added by direct SQL
|
McMurryIAS
![]()
Joined: 2009-12-01
Posts: 63 |
Posted: Tue, 2010-02-09 18:09
|
|
Given two .jpg files, one with keywords in the EXIF data, one without. Both properly uploaded to the Gallery. Let's call them with_keywords.jpg and missing_keywords.jpg. Now, let's say I use SQL to add keywords to the g2_Item.g_keywords field for missing_keywords.jpg. When I Edit Photo for with_keywords.jpg, I see data in the Keywords textarea. But when I Edit Photo for missing_keywords.jpg, the Keywords textarea is blank. Also, when viewing missing_keywords.jpg's resize page, there is no keyword list below it. After much experimentation, with .jpg files and other formats (even those without Exif data extracted by Gallery), it seems that the only way to get data to appear in the Keywords textarea, or on the resize page, is if 1) the original file had extractable keywords in it, or 2) the keywords have been added by Edit Photo. The most confusing part is, is that if I Edit Photo and add some keywords, the *only* field which is changed is g2_Item.g_keywords: The field I SQL'd in the first place! WHY IS THIS?
----- |
|


Posts: 6134
Did you clear gallery's database cache after adding the keywords?
And why wouldn't you use gallery's API in the first place?
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 4338
As supersidr says, all db queries are cached on disc. If you make changes to any db table outside the API you need to flush the db cache to see G2 pick up the new values.
Posts: 16501
This is a snippet from the Bulk Upload module written by Bharat:
http://codex.gallery2.org/Gallery2:Modules:bulkupload
I did not copy everything out, just the setting of KeyWords and as you can see from the note there is no API for doing that, but you can see how Bharat set them:
ItemAddBulk.inc:
/* Set the keywords by hand, since we don't offer that $ if (!empty($line['keywords'])) { list ($ret, $itemLockId) = GalleryCoreApi::acquireWriteLock($newItem->getId()); if ($ret) { return array($ret, null, null); } list ($ret, $newItem) = $newItem->refresh(); if ($ret) { return array($ret, null, null); } $newItem->setKeywords($line['keywords']); $ret = $newItem->save(); if ($ret) { return array($ret, null, null); } $ret = GalleryCoreApi::releaseLocks($itemLockId); if ($ret) { return array($ret, null, null); } } $newItemId = $newItem->getId(); } else {____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here