block-random.php fails after first attempt

scotts
scotts's picture

Joined: 2003-05-29
Posts: 3
Posted: Fri, 2003-12-26 06:03

I think I have a corrected a bug with standalone operation of the orginal Bharat Mediratta block-random.php code.

On redhat 9 running kernel 2.4.20-27.9 with the following rpms

# rpm -q httpd php
httpd-2.0.40-21.9
php-4.2.2-17.2

and gallery 1.41, the code would fail after first itteration. Reporting the following error:

Warning: rand() expects parameter 2 to be long, string given in /usr/share/bmfgallery/block-random2.php on line 138
ERROR: requested index [] out of bounds [10]
Fatal error: Call to a member function on a non-object in /usr/share/bmfgallery/classes/Album.php on line 962

Typecasiting the asignment corrected this problem.

# diff block-random.php.orig block-random.php
131c131
< $count = $cache[$album->fields["name"]];
---
> $count = (integer) $cache[$album->fields["name"]];

-scotts

 
someone
someone's picture

Joined: 2003-08-15
Posts: 2
Posted: Tue, 2003-12-30 22:54

Thanks alot! I have been trying to figures this one out for a while!

 
win2000b

Joined: 2003-04-11
Posts: 7
Posted: Mon, 2004-01-05 23:10

after trying loads of diff things I got this to eventually work. The solution I feel was a bit complicated. Simple thing to do is :-

1) EDIT block-random.php
2) FIND $count = $cache[$album->fields["name"]];
3) REPLACE IT WITH $count = (integer) $cache[$album->fields["name"]];

Save it. Should then work.