Error (ERROR_LOCK_REQUIRED) although read/write lock was acquired

somoebody7

Joined: 2006-09-06
Posts: 4
Posted: Wed, 2006-09-06 16:32

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

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-09-06 19:26

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.

 
somoebody7

Joined: 2006-09-06
Posts: 4
Posted: Wed, 2006-09-06 21:26

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

 
somoebody7

Joined: 2006-09-06
Posts: 4
Posted: Wed, 2006-09-06 21:46

hello again,

I'm sorry for such a mistake. valiant from irc solved it:

Quote:
the answer to your problem is: you forgot the "name" argument to addItemToAlbum(). the error message is bad though. partly due to php's lack of type-safety, partly because we don't check all arguments to the API call.