Hiya,
I'm playing around with the GalleryCoreApi::addItemToAlbum() function, but first I need to lock. But doing so I get an Error (ERROR_LOCK_REQUIRED).
Here is the code:
<?php
...
// Lock
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock(7);
echo "<br>1---<br><br>";
if ($ret) { echo $ret->getAsText(); exit; }
echo "<br>2---<br><br>";
list ($ret, $parentobj) = GalleryCoreApi::addItemToAlbum("/path/gallery2/g2data/albums/admin/arbeitsamt5.JPG", "PhotoTitle", "PhotoSummary", "PhotoDescription", "PhotoMimeType", 7, false);
echo "<br>3---<br><br>";
if ($ret) { echo $ret->getAsText(); exit; }
echo "<br>4---<br><br>";
// Free the lock
$ret = GalleryCoreApi::releaseLocks($lockId);
echo "<br>5---<br><br>";
if ($ret) { echo $ret->getAsText(); exit; }
echo "<br>6---<br><br>";
...
?>
Please note that's no serious code, so do not complain about other things. It's just a test.
The id 7 is valid, I tested it with other API functions. I also tried to use acquireReadLock(7) (and both together) but the result is the same.
And here the ouput:
1---
2---
3---
Error (ERROR_LOCK_REQUIRED)in modules/core/classes/GalleryDataItem.class at line 125 in modules/core/classes/GalleryUnknownItem.class at line 67 in modules/core/classes/helpers/GalleryItemHelper_medium.class at line 207
I've to mention that there is an old version of php on the server, 3.x - currently I can't check the version, but I will if I can (in some hours).
Any hint? Or can somebody reproduce this?
Thx,
Bye
Posts: 8601
you need a read lock on an album to add items in it, not a write lock.. a read lock just makes sure the album won't move around while you're adding.
Posts: 4
hello,
thanks for the info but as I mentioned before it also do not work with GalleryCoreApi::acquireReadLock(7).
Hm, phpinfo() output is disabled, but phpversion() works, it's PHP 4.2.2 - I was wrong.
Any hints?
Bye
Posts: 4
hello again,
I'm sorry for such a mistake. valiant from irc solved it: