fix: redeclare-error in 1.4.4-pl6 with gallery-random-block

jmoney
jmoney's picture

Joined: 2003-09-22
Posts: 11
Posted: Fri, 2005-02-11 15:57

hi,

after updating my gallery to 1.4.4-pl6 i found that it didn't work together with the random picture block for postnuke from www.holzapfel-online.de anymore. in case any of you have the same problem here's the fix:

in the gallery/init.php change line 132 from
require(dirname(__FILE__) . "/util.php"); to require_once(dirname(__FILE__) . "/util.php");

----
Gallery URL (optional but very useful): abinullfuenf.de
Gallery version: 1.4.4-pl6

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Fri, 2005-02-11 17:15

[Moved to correct forum]

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2005-02-11 17:20

jmoney, that's not correct. You will run into other issues if you try simply fixing it like that.

The random block is not designed to be included using include("/file/path") ... you MUST include the random block using include("http://.../block-random.php")

Please read the instructions listed at the top of this forum.

 
jmoney
jmoney's picture

Joined: 2003-09-22
Posts: 11
Posted: Fri, 2005-02-11 17:56

h0bbel: Sorry I thought I was using a completely different block, that's why I put it in the wrong forum.

signe: Please look at the download at http://www.holzapfel-online.de. That's a Wrapper for the gallery block with a possibility to change the appearance within the cms. The block (here called pnblocks/random.php) is included correctly. The problem that arose from that is that gallery as well as the block require('util.php') <b>when displayed simultaniously</b> on a page since they both include/require init.php which itself requires util.php. I suppose you could instead require_once('init.php') in the pnblocks/random.php and leave the main gallery distribution untouched. So far it has fixed my problem and I haven't run into any new problems.

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2005-02-11 18:03

jmoney, I know very well what the issue is, and I'm telling you that the random block is being included incorrectly.

Not the *nuke block, but the random block PHP file itself. The author of the file you downloaded did it wrong. Period.

 
jmoney
jmoney's picture

Joined: 2003-09-22
Posts: 11
Posted: Fri, 2005-02-11 18:20

Signe you're right. The author of the PN-block basically edited and renamed the block-random.php.
What kinds of problems would I have to expect with my solution? As I understand the "official" solution opens a new server thread so the scripts are run independent from another. What's so wrong about only requiring the file once for both scripts (which themselves are being included by the cms)? I would think that may even be the cleaner and possibly faster way.
I very much appreciate your suggestions and as you probably figure I am pretty new to PHP so please explain further.

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2005-02-11 18:28

jmoney, the main issue is that block-random.php is intended to (and tries to) run without sessions. That could cause conflicts or abnormalities with logged in users and other things like that. Depending on which block loads first, it could prevent Gallery from using sessions at all, which would prevent normal user operation entirely.

I agree that including the file directly is a lot more logical, and is definitely faster, but sadly it's not feasible with the G1 codebase. The random block in G2 is MUCH more robust and configurable than what G1 has.

 
jmoney
jmoney's picture

Joined: 2003-09-22
Posts: 11
Posted: Fri, 2005-02-11 20:19

Hi,

thanks for taking the time. I guess I have to surrender and go with the official solution ;)

Just two more questions: Does the gallery even need it's own sessions when embedded into postnuke? How does it know when an admin is logged in? I somehow can't imagine that I simply got lucky and the gallery loads before the random block. I'm usually unluckier than Murphy with this kind of things..

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2005-02-11 20:48

Gallery does use its own sessions, but not in the absolute sense. We maintain our own session cookie that's used to store gallery-specific information - we don't use the postnuke session. We do use postnuke to get the logged in user and other things like that, however.