| Author |
Message |
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Fri Apr 25, 2003 3:23 am Post subject: Block error: rand() & Call to a member function |
|
|
My page is at darkexodus.com, but I'll probably have this block admin only til I find the solution.
I installed the enhanced gallery block yesterday, and I was using the daily photo change, and it worked for two pics. Then today I woke up and I had this:
Warning: rand() expects parameter 2 to be long, string given in /home/wheelerw/public_html/mob/modules/gallery/random_support.php on line 203
ERROR: requested index [] out of bounds [39]
Fatal error: Call to a member function on a non-object in /home/wheelerw/public_html/mob/modules/gallery/classes/Album.php on line 642
Here's the code around line 203 in random_support:
Code: › function choosephoto($album) {
global $cache;
$count = $cache[$album->fields["name"]];
if ($count == 0) {
// Shouldn't happen
return null;
} else if ($count == 1) {
$choose = 1;
} else {
$choose = rand(1, $count);
$wrap = 0;
if ($album->isHidden($choose)) {
$choose++;
if ($choose > $album->numPhotos(1)) {
$choose = 1;
$wrap++;
if ($wrap = 2) {
return null;
}
}
}
Also, here is part of my sessions.php, as I figured it could be the problem because I had altered it yesterday. Notice that I commented out the top part of the code and replaced it with something else:
Code: › /* Start a new session, or resume our current one */
session_start();
/* emulate register_globals for sessions
if (!$gallery->register_globals) {
foreach($HTTP_SESSION_VARS as $key => $value) {
eval("\$$key = & \$HTTP_SESSION_VARS[\"$key\"];"); */
if (!$gallery->register_globals) {
foreach($_SESSION as $key => $value) {
eval("\$$key = & \$_SESSION[\"$key\"];");
}
}
And this last section is from around the area in Album.php that it said I had a fatal error:
Code: ›
function isHidden($index) {
$photo = $this->getPhoto($index);
return $photo->isHidden();
}
Last edited by dwellersire on Fri Apr 25, 2003 7:42 am; edited 1 time in total |
|
| Back to top |
|
|
AdBot
|
| Post subject: Block error: rand() & Call to a member function |
|
|
|
|
|
| Back to top |
|
 |
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Fri Apr 25, 2003 3:40 am Post subject: |
|
|
I'm running gallery 1.3.3
should I upgrade to the CVS? |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6271 Location: Washington Township, NJ, USA
|
Posted: Fri Apr 25, 2003 8:25 am Post subject: |
|
|
hmm...it may have tried to pull a picture from a hidden album, or one that only logged in users have permissions to view.
try upgrading to the latest CVS version (and then you won't have to apply the PHPNuke 6.5 patch to it) and see if it works. _________________
 |
|
| Back to top |
|
|
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Fri Apr 25, 2003 12:56 pm Post subject: |
|
|
I've upgraded to the latest CVS but same problem, plus I had to change the session.php file back to what it was to avoid another error.
I unhid all the pics and changed every permission to everybody, and it still has the errors. Also, I've changed the selector to random and tried to refresh, but still get the errors.
I think I just posted it wrong, but the problem on Album.php is on line 649, not 642. Same part of the code I posted though. |
|
| Back to top |
|
|
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Fri Apr 25, 2003 1:17 pm Post subject: |
|
|
Good news! I solved the problem by deleting, then restoring a backup of block-random.cache
I'll let you know if I run into it again |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6271 Location: Washington Township, NJ, USA
|
Posted: Fri Apr 25, 2003 1:22 pm Post subject: |
|
|
ah yes, that's a problem if the cache is messed up. glad to hear that it's worked out  _________________
 |
|
| Back to top |
|
|
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Sun May 04, 2003 3:43 am Post subject: |
|
|
I keep having this problem, about once every 3 days and it's getting annoying. I have a total of 2 hidden pics out of all of them so i dont see why hidden pics would be the problem....
Here's the latest contents of the .cache before it went kaput again:
Code: › album01/2
album04/2
album02/1
album03/63
album05/8
album06/24
album07/15
album08/13
album09/45
album10/43
album11/50
album12/20
album18/41
album20/29
And here is my daily.txt
Code: › http://host27.ipowerweb.com/~wheelerw/mob/modules.php?set_albumName=album11&id=img33&op=modload&name=gallery&file=index&include=view_photo.php http://host27.ipowerweb.com/~wheelerw/mob/modules.php?set_albumName=album11&op=modload&name=gallery&file=index&include=view_album.php DE Screenshots
Okay. The first daily pic I had before it went bad again was in album09.
The next one it where it messed up was album01 (if that's how the cache works). But the daily.txt file shows that that it's going to a screenshot from album11. album01 is the Dragon Empires directory. This directory has no screenshots, and only albums, thus the folder is empty. album11 is one of those subdirectories off of album01, actually holding the Dragon Empires screenshots.
Your thoughts? |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6271 Location: Washington Township, NJ, USA
|
Posted: Sun May 04, 2003 5:41 pm Post subject: |
|
|
hmm...yeah, the code generating the random image can crap out if the album has only subalbums and no actual photos. i'm working on something for another block that can fix this as well.
as for the cache file, it just contains the album name and the number of photos in the album. unfortunately, if it just contains sub albums, it still indexes the sub albums as photos, and can cause errors.
send me an email and/or PM with the random block and random support files that you're using so that i can check them out.
EDIT: see my post here [nukedgallery.net], dated Mon May 05, 2003 8:32 am. If your album ownership is not set to the webserver user, this could be the cause. _________________
 |
|
| Back to top |
|
|
dwellersire
Beginner


Joined: Apr 09, 2003 Posts: 6
|
Posted: Wed May 07, 2003 1:34 am Post subject: |
|
|
| It works off and on. I think I'll just upload some kinda dummy picture in the empty directories and see if it happens again. |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6271 Location: Washington Township, NJ, USA
|
Posted: Wed May 07, 2003 7:23 am Post subject: |
|
|
that should do it, especially since the probability that an image will be chosen out of an album is proportional to the number of pics in the album. i've submitted a patch request to the gallery team to assist me in solving this problem. _________________
 |
|
| Back to top |
|
|
yrret
Beginner


Joined: Apr 19, 2003 Posts: 3
|
|
| Back to top |
|
|
wellie
Beginner


Joined: Jul 30, 2003 Posts: 7
|
Posted: Thu Jul 31, 2003 11:15 pm Post subject: |
|
|
Any update on the patch for this problem? My gallery setup is lots of nested albums with not awhole lot of pics so this is a MAJOR bug for me. I would be thrilled if this was fixed!
 |
|
| Back to top |
|
|
corduroy
Beginner


Joined: Apr 17, 2003 Posts: 4
|
Posted: Fri Aug 01, 2003 1:56 am Post subject: Re: Block error: rand() & Call to a member function |
|
|
I had this problem happen about every 2-3 times when it refreshed. No hidden pictures, everything available publicly.
SOoooo....
kinda good news!
i found a way where it messes up VERY slightly now (I have it copletely on random and it has messed up only once)
first in your random_support.php, findCode: › function choosephoto($album) changeCode: › $choose = rand(1, $count); toCode: › $choose = rand(1, $count+1);
this only messes up when it picks the last picture in the album, but maybe someone with more experience in php can fix it better? |
|
| Back to top |
|
|
corduroy
Beginner


Joined: Apr 17, 2003 Posts: 4
|
Posted: Fri Aug 01, 2003 2:03 am Post subject: |
|
|
oh, and when it does mess up, on the next refresh a new picture comes up. _________________ www.colexusclub.com |
|
| Back to top |
|
|
wellie
Beginner


Joined: Jul 30, 2003 Posts: 7
|
Posted: Fri Aug 01, 2003 2:37 am Post subject: |
|
|
Quote: ›
I had this problem happen about every 2-3 times when it refreshed. No hidden pictures, everything available publicly.
Me too. And also I've put at least one photo in every album, so no albums with nothing but nested albums in them, but still the out of bounds error occurs with monotonous regularlity.
Quote: ›
i found a way where it messes up VERY slightly now
Thanks for the fix. Still it's annoying that the error still pops up when you choose the last pic in a gallery. My PHP is virtually non-existant - is there anyone who can come up with a fix for this  |
|
| Back to top |
|
|
|
|
|
|
|