Fixing cpg_show_private_album notice Fixing cpg_show_private_album notice
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Fixing cpg_show_private_album notice

Started by flar, April 28, 2006, 09:32:25 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

flar

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:

    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:

    $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:

function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG;

and change it to this:

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.

Paver

Thanks for the bug report & fix.  It works just as you wrote.

Committed to stable & devel branches.

Paver

This fix will be effectively reversed due to a follow-on bug caused by it.

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:
if (($cpg_show_private_album || $USER_DATA['can_see_all_albums']) && $cat == 0) {
with this line:
if ($USER_DATA['can_see_all_albums'] && $cat == 0) {

Will be committed once fully tested.

Paver

New correct fix committed to stable & devel.