Recent Topics

1 Nov 05, 2010 12:58    

My b2evolution Version: b2evolution v 4.0.0-alpha

Everytime I display categories In the back end I get an error:

Notice: Undefined index: 20 in /www/htdocs/w00d36d0/b2evo/inc/chapters/views/_chapter_list.view.php on line 116

I tried deleted all blogs and all categories and created some new test categories but the Index problem continues!

$edit_url = regenerate_url( 'action,cat_ID', 'cat_ID='.$Chapter->ID.'&action=edit' );
    $r .= '<td><a href="'.htmlspecialchars($Chapter->get_permanent_url()).'">'.$Chapter->dget('urlname').'</a></td>';

    if( $Settings->get('chapter_ordering') == 'manual' )
    {
        $r .= '<td class="center">'.$Chapter->dget('order').'</td>';
    }

    $r .= '<td class="center">'.(int)$number_of_posts_in_cat[$Chapter->ID].'</td>';

    $r .= '<td class="lastcol shrinkwrap">';
    if( $permission_to_edit )
    {    // We have permission permission to edit, so display action column:
        

Do I need more recent php or MYSQL ?

b2evolution-Zeit
05.11.10 - 12:58:04
MySQL
MySQL-Version
4.1.22-max-log
MySQL-UTF-8-Unterstützung
Ja
PHP
PHP läuft als BENUTZER:
wwwrun (uid 30)
PHP läuft als GRUPPE:
nogroup (gid 65534)
PHP-Version
4.4.9
PHP register_globals
An

2 Nov 05, 2010 21:53

This looks like a bug, I'll check it.

3 Nov 05, 2010 22:23

Try this

if( ! isset($number_of_posts_in_cat[$Chapter->ID]) ) $number_of_posts_in_cat[$Chapter->ID] = -1;
$r .= '<td class="center">'.(int)$number_of_posts_in_cat[$Chapter->ID].'</td>';


Then check the category that has "-1" posts, it's probably messed up.

4 Nov 05, 2010 22:25

Do I need more recent php or MYSQL ?

No doubt you should update to at least PHP 5.2 and MySQL 5.0

5 Dec 06, 2010 16:16

Replying to a PM here:

PHP 4.x is still supported by b2evolution (as far as I know), but I would always recommend the latest PHP (5.3.4 is about to get released).

This is not related to this bug however, a proposed fix was posted by Alex (sam2kb) - I have not verified it myself though.

6 Dec 06, 2010 19:07

@sam2kB

many thanx for your certainly competent help!
but I am not as deep into b2 as you, so where should I put that ? File ? Line ?

if( ! isset($number_of_posts_in_cat[$Chapter->ID]) ) $number_of_posts_in_cat[$Chapter->ID] = -1;
$r .= '<td class="center">'.(int)$number_of_posts_in_cat[$Chapter->ID].'</td>';

@blueyed

sure, I understand servers always should be upto date but I run a shared server in a hosting farm- so updateing to me means:
moving to another server in the same park - getting new IP - trouble with A.records, possible Sand-box in Google etc... so I would prefer avoiding a update of PHP and SQL if not REALLY needed!

7 Dec 07, 2010 00:32

Alex proposed to add the first line just above the second one.

The problem here is just that the $number_of_posts_in_cat array/map has no entry for the chapter in question (ID 20, therefore the "undefined index" notice).

The extra line ("if( ! isset ... )") just sets it to -1 in that case.

Looking at the current code in CVS (development version), it looks like there's still the same problem (as long as $number_of_posts_in_cat gets not handled differently).
(Here is a link to see the current file: https://github.com/whissip/whissip/blob/cvs-mirror/blogs/inc/chapters/views/_chapter_list.view.php#L116 (github mirror)).

Is there something special about your category with ID 20?
Does it not exist anymore, but gets called somehow?

8 Dec 07, 2010 00:48

Ok, looking at the code, this "global" $number_of_posts_in_cat only gets in this file and is the result of a left join (database).

This means that the category in question just has no posts assigned to it, and the notice is only cosmetic.

Instead of assigning -1 in that case, it should be "0".

I fixed it using "-" instead: https://github.com/whissip/whissip/commit/5e82f45dd918d8b96b85fb17f9837980ef71a6e7

You should be able to apply either this fix, or the one mentioned by Alex manually.

Please note that I won't commit anything to b2evo itself, so unless Alex fixes it in CVS, it might be still there with the next release.


Form is loading...