ERROR_LOCK_REQUIRED when calling GalleryCoreApi::addItemToAlbum

lukeco

Joined: 2009-04-08
Posts: 1
Posted: Wed, 2009-04-08 01:23

I'm trying to add new pictures to an album (any album). I've been messing around with this all day and I hoping someone can tell me what I'm doing wrong.

//Add Item to root album
list ($ret, $newItem) = GalleryCoreApi::addItemToAlbum(
$newItemPath, $filename, $title, $summary,
$description, $mimeType, $parent->getId());
if ($ret) {
GalleryCoreApi::releaseLocks($lockIds);
return array($ret, null, null);
}

If this code is called without the "if ($ret)" section, the item is not saved and the following error is thrown. If I don't do error checking, the item is saved.

Error (ERROR_LOCK_REQUIRED)
* in modules/core/classes/GalleryEntity.class at line 266 (GalleryCoreApi::error)
* in modules/core/classes/GalleryItem.class at line 414 (GalleryEntity::save)
* in modules/embedtags/classes/EmbedTags.class at line 239 (GalleryItem::save)
* in modules/embedtags/classes/EmbedTags.class at line 122 (EmbedTags::create)
* in modules/core/AdminMaintenance.inc at line 128 (EmbedTags::run)

I've posted a more complete chunk of code here:
http://pastie.org/440297

Thanks to anyone who can help!

Luke

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-04-08 07:22

Print_r the contents of the $lockIds array at various places and make sure it contains what you think it does.