forum.coppermine-gallery.net

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: flar on April 28, 2006, 09:32:25 am

Title: Fixing cpg_show_private_album notice
Post by: flar on April 28, 2006, 09:32:25 am
I turned on debug and notices today to see what it might turn up and found a couple of niggly problems.  One of these is the notice:

Quote
/include/themes.inc.php
  • Notice line 88: Undefined variable: cpg_show_private_album

which a search turns up on many support messages in this forum and it turned out to be easy to fix.  First I noticed that it is used in the get_meta_album_set function which index.php calls before it sets the variable.  This was easy to fix by just moving the line in index.php:

Find this in index.php:
Code: [Select]
    if (isset($cat)) {
        get_meta_album_set($cat,$META_ALBUM_SET);
    } else {
        get_meta_album_set(0,$META_ALBUM_SET);
    }

    $cpg_show_private_album = ($CONFIG['allow_private_albums'])?($CONFIG['show_private']):(true);

    get_cat_list($breadcrumb, $cat_data, $statistics);
and change it to this:
Code: [Select]
    $cpg_show_private_album = ($CONFIG['allow_private_albums'])?($CONFIG['show_private']):(true);

    if (isset($cat)) {
        get_meta_album_set($cat,$META_ALBUM_SET);
    } else {
        get_meta_album_set(0,$META_ALBUM_SET);
    }

    get_cat_list($breadcrumb, $cat_data, $statistics);

While that is probably needed for proper function (I didn't actually test this as I don't use private albums), it didn't silence the notice.  To do that you need to add $cpg_show_private_album to the list of globals in get_meta_album_set.

Find this in include/functions.inc.php:
Code: [Select]
function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG;
and change it to this:
Code: [Select]
function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG, $cpg_show_private_album;

and the notice disappears.

Please note that I didn't test the proper operation of any of these changes on the use of private albums as I don't use them on my site, but they do fix the notice and they appear to be fairly straightforward and otherwise harmless code fixes from inspection alone so I hope they help someone.
Title: Re: Fixing cpg_show_private_album notice
Post by: Paver on May 18, 2006, 05:44:55 am
Thanks for the bug report & fix.  It works just as you wrote.

Committed to stable & devel branches.
Title: Re: Fixing cpg_show_private_album notice
Post by: Paver on June 03, 2006, 04:04:06 am
This fix will be effectively reversed due to a follow-on bug caused by it (http://forum.coppermine-gallery.net/index.php?topic=32091.0).

The new fix is to remove $cpg_show_private_album from the function get_meta_album_set() in functions.inc.php.

So, replace this line:
Code: [Select]
if (($cpg_show_private_album || $USER_DATA['can_see_all_albums']) && $cat == 0) {with this line:
Code: [Select]
if ($USER_DATA['can_see_all_albums'] && $cat == 0) {
Will be committed once fully tested.
Title: Re: Fixing cpg_show_private_album notice
Post by: Paver on June 04, 2006, 11:27:04 pm
New correct fix committed to stable & devel.