#1406 mod-forums_last_posts: Generates fatal PHP errors

All_versions
closed-fixed
PHP Error (166)
5
2005-01-24
2004-03-26
Anonymous
No

The following lines are displayed when I requested any
tiki page:

Notice: Undefined offset: 3
in /home/likgbugc/public_html/tiki/modules/mod-
forums_last_posts.php on line 11

Notice: Undefined offset: 4
in /home/likgbugc/public_html/tiki/modules/mod-
forums_last_posts.php on line 11

Notice: Undefined offset: 5
in /home/likgbugc/public_html/tiki/modules/mod-
forums_last_posts.php on line 11

<snip 1000s of similar lines>

Any page simply displayed thousands of these lines. No
tiki formatting can be seen, just this basic html. The
lines seem to go on infinitely (i stopped when the offset
got to about 10,000).

I managed to fix this to get my tiki up and running by
editing the mod-forums_last_posts.php and commenting
out the entire loop surrounding line 11. But obviously this
is just a hack... there is still a problem with the array
(and my guess is it is something to do with the count()
function returning an incorrect value).

Anything I can do to help: ant @ harfield . org . uk

Antony Harfield

Discussion

  • Philippe Cloutier

    • summary: mod-forums_last_posts: Problem causes tiki failure --> mod-forums_last_posts: Generates fatal PHP errors
    • labels: 544453 --> PHP Error
    • status: open --> open-works-for-me
     
  • Philippe Cloutier

    Logged In: YES
    user_id=738765

    Hi, i don't get this, maybe you could restore the original
    file, unassign the module and check if reassigning it would
    do the same thing :P WHen you get a "crash", edit the table
    tiki_modules and delete the problematic row.

     
  • Philippe Cloutier

    Logged In: YES
    user_id=738765

    So, can you reproduce this with let's say a fresh 1.8.2?

     
  • Nobody/Anonymous

    Logged In: NO

    haitipro@haitipro.com wrote:

    I have been experiencing a similar problem with a fresh 1.8.2
    install. the web page never load when I try to preview this
    module prior to assignment

     
  • Oliver Hertel

    Oliver Hertel - 2004-05-18
    • assigned_to: nobody --> ohertel
     
  • Oliver Hertel

    Oliver Hertel - 2004-06-01
    • status: open-works-for-me --> closed-fixed
     
  • LucSQRT1

    LucSQRT1 - 2004-11-16

    Logged In: YES
    user_id=1159940

    What is the latest on this bug? I just moved a running tiki site
    from one host to another, and I have this very error on the
    new server both on a fresh 1.8.4 install and when importing
    the db from the old server. So I can't consider this bug gone,
    it's definitely still there for me in 1.8.4. Let me know if there's
    things I should try or info that would be helpful to debug this.
    tks

     
  • Philippe Cloutier

    Logged In: YES
    user_id=738765

    Can you post your error messages just to be sure you have
    the same problem in 1.8.4?
    What does count($ranking["data"]) return?
    Oliver, do you think it should use just foreach instead of for?
    Oliver considered this bug to be due to the problem
    described in [ 963505 ] Bug in mod-forums_last_posts
    https://sourceforge.net/tracker/?group_id=64258&atid=506846&func=detail&aid=963505

     
  • Philippe Cloutier

    • milestone: 383505 --> 422327
    • status: closed-fixed --> open
     
  • LucSQRT1

    LucSQRT1 - 2004-11-16

    Logged In: YES
    user_id=1159940

    When restoring the original mod-forums_last_posts.php from
    1.8.4 I get the following html (literally, the html source has
    nothing more than a bit of <br/> and bolding):

    Notice: Undefined offset: 4
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 16

    Notice: Undefined offset: 5
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 16

    Notice: Undefined offset: 6
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 16

    Notice: Undefined offset: 7
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 16

    This goes on seemingly forever. This is IMO exactly the same
    as the original post, except it starts at offset 4 not 3.

    I don't think it has to do with [ 963505 ]; the variable used is
    $flp not $i; and it doesn't seem to be initialized when running
    the php (see dumps below).

    I inserted the following dump instructions before if($ranking)
    and outcommented the for loop; see further for the results of
    this:

    echo '$ranking=' . $ranking . '<br/>';
    echo '$ranking["data"]=' . $ranking["data"] . '<br/>';
    echo 'count($ranking["data"])=' . count($ranking
    ["data"]) . '<br/>';
    echo '$ranking["data"][0]=' . $ranking["data"][0] . '<br/>';
    echo '$ranking["data"][4]["name"]=' . $ranking["data"][4]
    ["name"] . '<br/>';
    echo '$flp=' . $flp . '<br/>';
    echo '$name=' . $name . '<br/>';
    echo '$replyprefix=' . $replyprefix . '<br/>';

    foreach ($ranking["data"] as $k => $v) {
    echo '$ranking["data"][' . $k . ']["name"] => ' . $v
    ["name"] . '<br/>';
    }

    foreach ($ranking["data"]["data"] as $k => $v) {
    echo '$ranking["data"]["data"][' . $k . ']["name"] => ' . $v
    ["name"] . '<br/>';
    }

    RESULTS:

    $ranking=Array
    $ranking["data"]=Array
    count($ranking["data"])=5
    $ranking["data"][0]=Array

    Notice: Undefined offset: 4
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 18
    $ranking["data"][4]["name"]=

    Notice: Undefined variable: flp
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 19
    $flp=
    $name=title
    $replyprefix=Re:
    $ranking["data"][0]["name"] => VT Discussies: Re: Re:
    Wapenschild
    $ranking["data"][1]["name"] => VT Discussies: Re:
    Wapenschild
    $ranking["data"][2]["name"] => VT Discussies: Re:
    Wapenschild
    $ranking["data"][3]["name"] => VT Discussies: Wapenschild

    Notice: Undefined index: name
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 24
    $ranking["data"][data]["name"] =>
    $ranking["data"]["data"][0]["name"] => VT Discussies: Re: Re:
    Wapenschild
    $ranking["data"]["data"][1]["name"] => VT Discussies: Re:
    Wapenschild
    $ranking["data"]["data"][2]["name"] => VT Discussies: Re:
    Wapenschild
    $ranking["data"]["data"][3]["name"] => VT Discussies:
    Wapenschild

    Notice: Undefined index: name
    in /home/httpd/vhosts/httpdocs/tiki/modules/mod-
    forums_last_posts.php on line 28
    $ranking["data"]["data"][data]["name"] =>

    My $.02: for some reason, the array has one more element
    that is not numeric index but "data", which appears to hold a
    reference to the array again. The for loop becomes infinite
    because $flp is never bigger than count($ranking..), since
    within the loop, a new array element is inserted.
    This bug should occur always when that "data" element is in
    the array; so the source of the problem is probably not in this
    loop but in how did this "data" element ever get in the
    array???
    hope this helps!

     
  • Philippe Cloutier

    Logged In: YES
    user_id=738765

    You certainly just did most of the work toward this bug's
    resolution, however I'm still unable to spot where
    $ranking["data"]["data"] would be defined. With what you
    already found, I'm sure you can help find that last clue
    before this get can be fixed.
    Try var_dump($ranking); at various times, that should help
    you quickly.
    Does
    var_dump($ranklib->forums_ranking_last_posts($module_rows));
    already contain the bogus element?
    Just in case, what's your version of PHP?

     
  • LucSQRT1

    LucSQRT1 - 2004-11-17

    Logged In: YES
    user_id=1159940

    Yes, var_dump($ranklib->forums_ranking_last_posts
    ($module_rows)) does have the bogus element and has it
    recursively:

    array(7) { [0]=> array(3) { ["name"]=> string(34) "VT
    Discussies: Re: Re: Wapenschild" ["hits"]=> string
    (43) "dinsdag 19 of October, 2004 [00:37:31 CEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [1]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(43) "maandag 18 of October, 2004 [21:05:24 CEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [2]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(42) "zondag 17 of October, 2004 [21:39:35 CEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [3]=> array(3) { ["name"]
    => string(26) "VT Discussies: Wapenschild" ["hits"]=> string
    (43) "zatedag 16 of October, 2004 [20:06:19 CEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } ["data"]=> array(5) { [0]
    => array(3) { ["name"]=> string(34) "VT Discussies: Re: Re:
    Wapenschild" ["hits"]=> string(43) "dinsdag 19 of October,
    2004 [00:37:31 CEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [1]=> array(3) { ["name"]=> string(30) "VT Discussies: Re:
    Wapenschild" ["hits"]=> string(43) "maandag 18 of October,
    2004 [21:05:24 CEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [2]=> array(3) { ["name"]=> string(30) "VT Discussies: Re:
    Wapenschild" ["hits"]=> string(42) "zondag 17 of October,
    2004 [21:39:35 CEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [3]=> array(3) { ["name"]=> string(26) "VT Discussies:
    Wapenschild" ["hits"]=> string(43) "zatedag 16 of October,
    2004 [20:06:19 CEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    ["data"]=> array(5) { [0]=> array(3) { ["name"]=> string
    (34) "VT Discussies: Re: Re: Wapenschild" ["hits"]=> string
    (43) "dinsdag 19 of October, 2004 [00:37:31 CEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [1]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(43) "maandag 18 of October, 2004 [21:05:24 CEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [2]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(42) "zondag 17 of October, 2004 [21:39:35 CEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [3]=> array(3) { ["name"]
    => string(26) "VT Discussies: Wapenschild" ["hits"]=> string
    (43) "zatedag 16 of October, 2004 [20:06:19 CEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } ["data"]=>
    *RECURSION* } } ["title"]=> string(25) "Forums' laatste
    berichten" ["y"]=> string(15) "Datum onderwerp" }

    PHP Version is 4.3.8

    Looking at the function forums_ranking_last_posts in
    lib/rankings/ranklib.php I think the offending line is:
    $ret["data"] = $ret;
    after this line, $ret does contain the recursion. I remarked
    that in some of the other functions in the lib, the line looks a
    bit different:
    $retval["data"] = $ret;

    Changing the lines to
    $retval["data"] = $ret;
    $retval["title"] = tra("Forums last posts");
    $retval["y"] = tra("Topic date");
    return $retval;
    solves the problem and mod-forums_last_posts.php works fine
    again!
    Note that this fix is probably needed in all the other functions
    of the ranklib too.

    Rendered me curious to why it didn't fail on my other server.
    There, dump_var($ret) in forums_ranking_last_posts returns:

    array(5) { [0]=> array(3) { ["name"]=> string(34) "VT
    Discussies: Re: Re: Wapenschild" ["hits"]=> string
    (43) "dinsdag 19 of October, 2004 [03:37:31 EEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [1]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(43) "maandag 18 of October, 2004 [21:05:24 EEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [2]=> array(3) { ["name"]
    => string(30) "VT Discussies: Re: Wapenschild" ["hits"]=>
    string(42) "zondag 17 of October, 2004 [21:39:35 EEST]"
    ["href"]=> string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } [3]=> array(3) { ["name"]
    => string(26) "VT Discussies: Wapenschild" ["hits"]=> string
    (43) "zatedag 16 of October, 2004 [20:06:19 EEST]" ["href"]
    => string(60) "tiki-view_forum_thread.php?
    forumId=1&comments_parentId=1" } ["data"]=> array(4) { [0]
    => array(3) { ["name"]=> string(34) "VT Discussies: Re: Re:
    Wapenschild" ["hits"]=> string(43) "dinsdag 19 of October,
    2004 [03:37:31 EEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [1]=> array(3) { ["name"]=> string(30) "VT Discussies: Re:
    Wapenschild" ["hits"]=> string(43) "maandag 18 of October,
    2004 [21:05:24 EEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [2]=> array(3) { ["name"]=> string(30) "VT Discussies: Re:
    Wapenschild" ["hits"]=> string(42) "zondag 17 of October,
    2004 [21:39:35 EEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?forumId=1&comments_parentId=1" }
    [3]=> array(3) { ["name"]=> string(26) "VT Discussies:
    Wapenschild" ["hits"]=> string(43) "zatedag 16 of October,
    2004 [20:06:19 EEST]" ["href"]=> string(60) "tiki-
    view_forum_thread.php?
    forumId=1&comments_parentId=1" } } }

    So it has the ["data"] element once, but not recursively so no
    ["data"]["data"] and therefore it works. I'd still say it's a bit
    ugly because $ret basically contains the information at two
    levels.
    Note that this other server is running PHP 4.3.4; could that
    explain?

     
  • Philippe Cloutier

    • milestone: 422327 --> All_versions
    • status: open --> open-fixed
     
  • Philippe Cloutier

    Logged In: YES
    user_id=738765

    OK, you found the problem...I fixed that for 1.8.5 :)
    As you say though, it's not clear why your PHP behaves that way.
    The array on your "working" server does contain a
    duplication of itself, approximately speaking. That doesn't
    break it and only constitutes a minor memory inefficiency.

    If you're as curious as me and really want to know why your
    new server makes the array infinitely recursive instead of
    just duplicating the array once, place
    var_dump($ret);
    both before and after
    $ret["data"] = $ret;
    According to what you report, I would expect that before,
    the array is normal, without data key, and after the
    var_dump will be infinite. This looks like
    $ret["data"] = $ret;
    is interpreted as an assignation by reference.
    The fact that you use PHP 4.3.8 would hardly explain that
    since this bug report was opened before its release. I don't
    experience that with 4.3.9. I'm not really good in
    PHP...could it be some setting??? If you really wish to
    find, I guess you can let me know :)

     
  • LucSQRT1

    LucSQRT1 - 2004-11-18

    Logged In: YES
    user_id=1159940

    var_dump($ret); before and after the instruction was how I
    found the 'offending' line; indeed before the array has just the
    4 actual elements; after this it has the 'data' element that
    itself contains the 4 numbered elements plus again 'data' and
    so on.
    I'm not at all familiar with PHP and I'm also not controlling this
    server or its settings. So while curious I'm afraid I can't help
    unless someone could suggest what precisely to look for. The
    fact that others have seen it, even with other versions of
    PHP, does suggest it could be something different than PHP
    itself? Is PHP depending on some other components?
    Thanks anyway for the help so far, at least that helped
    solving the issue that was blocking my site from running.

     
  • Philippe Cloutier

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.