Hi,
I'm trying to use the UserAlbum module to automatically create a new album when the account is created... but I'm using the embed.php "createUser" API. The combination seems to create this error:
Error (ERROR_MISSING_OBJECT) : Missing object for 14
* in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 2041 (gallerystatus::error)
* in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 305 (mysqldatabasestorage::_identifyentities)
* in modules/core/classes/GalleryStorage.class at line 113 (mysqldatabasestorage::loadentities)
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 82 (gallerystorage::loadentities)
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 141 (galleryentityhelper_simple::loadentitiesbyid)
* in modules/core/classes/GalleryCoreApi.class at line 2151 (galleryentityhelper_simple::loadentitybyexternalid)
* in embed.php at line 159 (gallerycoreapi::loadentitybyexternalid)
* in embed.php at line 75 (galleryembed::checkactiveuser)
* in /home/rk/www/gallery2.php at line 27 (galleryembed::init)
My code looks like this (the last line of real code is line 27):
$ret = GalleryEmbed::init(array('embedUri'=>'gallery2.php',
'embedPath'=>'/', 'relativeG2Path'=>'gallery2/',
'activeUserId' => $activeuser));
if ( $ret->isError()) {
if ( $ret->getErrorCode() & ERROR_MISSING_OBJECT )
{
GalleryEmbed::done();
GalleryEmbed::init();
$ret = GalleryEmbed::createUser($activeuser, array('username'=>$activeuser));
if ( !$ret->isError() )
GalleryEmbed::done();
$ret = GalleryEmbed::init(array('embedUri'=>'gallery2.php',
'embedPath'=>'/', 'relativeG2Path'=>'gallery2/',
'activeUserId' => $activeuser));
}
}
The reason for the first ERROR_MISSING_OBJECT is because the user doesn't exist yet in the system. However, on the second attempt, the user does exist, yet I still get this error. Am I doing something obviously wrong or is this a bug?
Posts: 7
Just a bit more information... it looks like the ID number is messed up after the album is getting created. Here's some query results:
Posts: 32509
rkuris, see http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=25979&postdays=0&postorder=asc&start=150#133447
GalleryEmbed::done();
GalleryEmbed::init();
isn't required after the error.
but after the GalleryEmbed::createUser, you need to call ::done, but only if no ::handleRequest() fallows upon ::createUser.
Posts: 7
That was just for testing. The problem still occurs.
This patch/hack (yes, I know it is WRONG), however, works around the problem, which indicates this is some sort of bug deeper in the code than I care to venture at the moment.
Posts: 32509
?? what do you accomplish with the additional line "$user->getId(); " in GalleryEmbed::createUser?
you don't even assign the id to something, neither you print it out.
What's your intention/goal?
Posts: 7
Yeah, I know. Apparently, by doing this, it caches the ID number in the user structure so when it gets used later, it's correct.
I think the ID number is computed by calling mysql_insert_id or selecting LAST_INSERT_ID somewhere, but it was too late. I think it was too late because the UserAlbum module did some stuff, inserting some rows (possibly in the Entity table?) messing things up.
Posts: 32509
rkuris, I've just tested it in my xaraya integration. Useralbum + GalleryEmbed::createUser works without a problem.
Posts: 7
Did you turn on the "Auto create album when the account is created" option? It won't fail without it.
Posts: 32509
yes i have. it works.
what G2 version or you using? (although it should work since a long time)
Your code is slightly different from mine.
After createUser, just call checkActiveUser and then handlerequest.
Posts: 7
I pulled the code from CVS a few days back. I just did another update now, and I'll retest.
Posts: 7
Well, the update is hanging waiting on a mindless lock (interesting pun there). I'll test it once I get the update installed.