Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: get_meta_album_set_data()  (Read 7301 times)

0 Members and 1 Guest are viewing this topic.

Titooy

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 736
    • under construction...
get_meta_album_set_data()
« on: September 06, 2005, 01:35:50 am »

That function shouldn't be called if there's no meta album on the page since it means such a terrible sql load on big galleries. By the way, if cat=0 $meta_album_set is the same as $album_set so there is no need to calculate it, even if you show meta albums.
« Last Edit: November 03, 2005, 08:33:31 am by GauGau »
Logged

Titooy

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 736
    • under construction...
Re: get_meta_album_set_data()
« Reply #1 on: October 16, 2005, 07:16:53 pm »

I modified get_meta_album_set_data() and get_meta_album_set() so that the root page loads much faster and the other pages loads a bit faster.

Code: [Select]
/**
 * get_meta_album_set_data()
 *
 * Get the entire album set based on the current category, this function is called recursively.
 *
 * ** Experimental, may cause sql problems on galleries with large numbers of albums.
 *
 * @param integer $cid Parent Category
 * @param array $meta_album_set_array
 * @return void
 **/
function get_meta_album_set_data($cid,&$meta_album_set_array) //adapted from index.php get_subcat_data()
{
    global $CONFIG, $cat;

    if ($cid == USER_GAL_CAT) {
       $sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category>=" . FIRST_USER_CAT;
       $result = cpg_db_query($sql);
       $album_count = mysql_num_rows($result);
       while ($row = mysql_fetch_array($result)) {
           $meta_album_set_array[] = $row['aid'];
       } // while
       mysql_free_result($result);
    } else {
       $result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$cid}");
       $album_count = mysql_num_rows($result);
       while ($row = mysql_fetch_array($result)) {
           $meta_album_set_array[] = $row['aid'];
       } // while

       mysql_free_result($result);
    }

    $result = cpg_db_query("SELECT cid FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$cid'");

    if (mysql_num_rows($result) > 0) {
        $rowset = cpg_db_fetch_rowset($result);
        foreach ($rowset as $subcat) {
            if ($subcat['cid']) {
                get_meta_album_set_data($subcat['cid'], $meta_album_set_array);
            }
        }
    }
}

/**
 * get_meta_album_set()
 *
 * Get the entire album set based on the current category.
 *
 * @param integer $cat Category
 * @param array $meta_album_set_array
 * @return void
 **/
function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG;
    if ($cpg_show_private_album || $USER_DATA['can_see_all_albums'] && $cat == 0) {
        $meta_album_set ='';
    } elseif ($cat < 0) {
        $meta_album_set= 'AND aid IN (' . (- $cat) . ') ';
    } elseif ($cat > 0) {
       $meta_album_set_array=array();
        get_meta_album_set_data($cat,$meta_album_set_array);
        $meta_album_set_array = array_diff($meta_album_set_array,$FORBIDDEN_SET_DATA);

        if (count($meta_album_set_array)) {
            $meta_album_set = "AND aid IN (" . implode(',',$meta_album_set_array) . ") ";
        } else {
            $meta_album_set = "AND aid IN (-1) ";
        }
     } else {
      $result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']}");
        $album_count = mysql_num_rows($result);
        while ($row = mysql_fetch_array($result)) {
           $meta_album_set_array[] = $row['aid'];
        }
        mysql_free_result($result);
        $meta_album_set_array = array_diff($meta_album_set_array,$FORBIDDEN_SET_DATA);

        if (count($meta_album_set_array)) {
            $meta_album_set = "AND aid IN (" . implode(',',$meta_album_set_array) . ") ";
        } else {
            $meta_album_set = "AND aid IN (-1) ";
        }
     }
}
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: get_meta_album_set_data()
« Reply #2 on: October 21, 2005, 11:21:55 pm »

we have a feature freeze for cpg1.4.x, so we should not implement this now for cpg1.4.x
However, this should be looked into for cpg1.5.x, that's why I'm moving this thread from "CPG 1.4 Testing/Bugs" to "Scheduled for cpg1.5.x"
Logged

Titooy

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 736
    • under construction...
Re: get_meta_album_set_data()
« Reply #3 on: October 24, 2005, 01:04:14 am »

It's not at all a new feature. It's just a faster way to implement a features that is included in the current cvs but that slows down very much big galleries. That feature is currently commented:
Quote
** Experimental, may cause sql problems on galleries with large numbers of albums.
so I presume it's meant to be improved. That's just what I did...
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: get_meta_album_set_data()
« Reply #4 on: November 03, 2005, 08:34:59 am »

kegobeer has added your code to the devel branch of the cvs - this means the code will go into cpg1.4.x (see http://forum.coppermine-gallery.net/index.php?topic=23311.0)
Logged
Pages: [1]   Go Up
 

Page created in 0.015 seconds with 19 queries.