Excessive time to log out or load index page - zp Ardoise

EDIT: Slow response is caused by turning on Image statistic strip to "Random". Tested "latest", no problems. This may be theme issue. Not familiar with Image Statistic Strip on other themes.

I'm getting excessive load times of the index page when the user is not logged in. The initial load time when not logged in is around 87,000ms. After logging in, reloading the page, after emptying the cache is only 360ms. Logging out is also excessive at 79,000ms.

But.....going to directly to....... /zp-core/admin.php when not logged in (empty cache) is only 477ms.

I think it must be a database issue. I have 2 other Joomla based MySQL sites on same setup that load relatively quickly (300ms) initial load with empty cache.

I am not on a dedicated server.

MySQL version: 5.0.96, PHP Version 5.3.14, ZP 1.4.4.1b

http://www.loweprofile.com/gallery/
http://www.loweprofile.com/gallery/zp-core/admin.php

Any ideas what is causing the slow response.

Comments

  • This is interesting. A user not logged in does not have permission to see the images in the image strip, so it is empty, but the server appears to be using up time trying to figure out what to do.

    Not sure why this would effect logging out. Using the "latest" option does not effect logout either.

    If "random" is selected, once user is logged in, different random images are loaded on every user refresh.
  • acrylian Administrator, Developer
    "Not sure why this would effect logging out. Using the "latest" option does not effect logout either."
    Soes the theme use the image_album_statistics function to get the random images?

    Just tried to visit the site (the admin link of course has no use for anyone here) and the page is not compeltely rendered. So you should now do what you should have done already actually: Look at your server error log for any errors.
  • The admin link demonstrates the load time to reach the login page. Which is much quicker because that page does not call fro random images.

    Here is the code:
    `
    <?php if ((getOption('image_statistic') != 'none') && ((function_exists('printImageStatistic')) || (getOption('image_statistic') == 'random'))) { ?>
    <?php include('inc_print_image_statistic.php'); ?>
    <?php } ?>
    `
  • acrylian Administrator, Developer
    Ok... But your front page is that slow that this does not need any comparison..:-)

    That code does not really help. The file included is a special theme based one. What functions does it use?
  • I think Vincent will have to step in here. It looks like is using his code to generate random image strip. I have to wait overnight to get an updated server log.

    `
    /* zpArdoise_printImageStatistic

    - use improvements of zenphoto 1.4.2 on printRandomImages and printImageStatistic (http://www.zenphoto.org/trac/ticket/1914)

    - implements call of colorbox (http://www.zenphoto.org/trac/ticket/1908 and http://www.zenphoto.org/trac/ticket/1909)

    */

    function zpArdoise_printImageStatistic($number, $option, $albumfolder='', $showtitle=false, $showdate=false, $showdesc=false, $desclength=40, $showstatistic='', $width=NULL, $height=NULL, $crop=NULL, $collection=false, $fullimagelink=false, $a_class=NULL) {

    $images = getImageStatistic($number, $option, $albumfolder,$collection);

    if (is_null($crop) && is_null($width) && is_null($height)) {

    $crop = 2;

    } else {

    if (is_null($width)) $width = 85;

    if (is_null($height)) $height = 85;

    if (is_null($crop)) $crop = true;

    }

    echo "\n
    \n";

    echo "
      ";

      foreach ($images as $image) {

      $fullimage = getFullImageURL($image);

      if(($fullimagelink) && (!empty($fullimage))) {

      $aa_class = ' class="' . $a_class . '"';

      $imagelink = html_encode($fullimage);

      } else {

      $aa_class = NULL;

      $imagelink = html_encode(getURL($image));

      }

      echo "
    • getTitle()) . "\">\n";

      switch ($crop) {

      case 0:

      echo "imagegetCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . "\" alt=\"" . html_encode($image->getTitle()) . "\" />
      \n";

      break;

      case 1:

      echo "imagegetCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, TRUE)) . "\" alt=\"" . html_encode($image->getTitle()) . "\" />\n";

      break;

      case 2:

      echo "imagegetThumb()) . "\" alt=\"" . html_encode($image->getTitle()) . "\" />\n
      ";

      break;

      }

      if($showtitle) {

      echo "

      getImageLink()) . "\" title=\"" . html_encode($image->getTitle()) . "\">\n";

      echo $image->getTitle() . "

      \n";

      }

      if($showdate) {

      echo "

      " . zpFormattedDate(DATE_FORMAT,strtotime($image->getDateTime())) . "

      ";

      }

      if($showstatistic === "rating" OR $showstatistic === "rating+hitcounter") {

      $votes = $image->get("total_votes");

      $value = $image->get("total_value");

      if($votes != 0) {

      $rating = round($value/$votes, 1);

      }

      echo "

      " . sprintf(gettext('Rating: %1$u (Votes: %2$u)'), $rating, $votes) . "

      ";

      }

      if($showstatistic === "hitcounter" OR $showstatistic === "rating+hitcounter") {

      $hitcounter = $image->get("hitcounter");

      if(empty($hitcounter)) { $hitcounter = "0"; }

      echo "

      " . sprintf(gettext("Views: %u"), $hitcounter) . "

      ";

      }

      if($showdesc) {

      echo shortenContent($image->getDesc(), $desclength,' (...)');

      }

      echo "
    • ";

      }

      echo "
    \n";

    }
    `
  • acrylian Administrator, Developer
    Indeed that is not our statistics function (which has a random sortorder as well).
  • Vincent, maybe a way to handle this would be "if" user is not logged in, no image strip is displayed. On my site a user not logged in does not have permissions to see those images anyway, so the strip is empty.

    Just a thought. Might not work well for other situations, where admin wants not logged in users to see image strip.
  • vincent3569 Member, Translator
    hi

    I have no proble with zpArdoise_printRandomImages who follows printRandomImages code.

    @tplowe56 : please, could you have some tests ?

    1/ in my theme zpArdoise, replace code (backup original file before) :
    inc_print_image_statistic.php, lines 30 to 34

    replace
    `
    if (getOption('use_colorbox_album')) {
    zpArdoise_printRandomImages($number, NULL, 'all', '', NULL, NULL, NULL, true, 'colorbox');
    } else {
    zpArdoise_printRandomImages($number, NULL, 'all', '', NULL, NULL, NULL, false);
    }
    `
    by
    `
    if (getOption('use_colorbox_album')) {
    printRandomImages($number);
    } else {
    printRandomImages($number);
    }
    `
    2/ in official garland theme, replace code (backup original file before) :
    gallery.php, line 75 to 82

    replace
    `
    <?php
    if (function_exists('printLatestImages')) {
    ?>

    <?php echo gettext('Latest Images'); ?>

    <?php
    printLatestImages(7);
    }
    ?>
    `
    by
    `
    <?php
    if (function_exists('printRandomImages')) {
    ?>

    <?php echo gettext('Latest Images'); ?>

    <?php
    printRandomImages(7);
    }
    ?>
    `
    and let us know the results
  • I made the code changes and I still have long load times.

    64,000ms when not logged in
    1,082ms when logged in

    There is no PM on this forum. I will grant full access to site, if you want, through other communication.
  • Just to be sure I replaced all my changed files with original zpArdoise theme files. The loading times did not improve. My modifications are purely cosmetic, but I wanted to make sure they had not caused a problem.
  • vincent3569 Member, Translator
    So the problem is not due to zpardoise function itself and this is not an issue of my theme.

    I'll tell you the back of my mind: all your albums are protected by a password, but your gallery is public.
    so, show recent images or random pictures is a nonsense.

    if you want to keep your albums protected, you'd better not show images (Image Show Statistic strip = none), or you could display these images only if you are connected, by wrapping existing code like that (in gallery.php, lines 26 to 28) :

    `
    <?php if (zp_loggedin()) { ?>
    <?php if ((getOption('image_statistic') != 'none') && ((function_exists('printImageStatistic')) || (getOption('image_statistic') == 'random'))) { ?>
    <?php include('inc_print_image_statistic.php'); ?>
    <?php } ?>
    <?php } ?>
    `
    another solution : you could protect your gallery with a password (admin/gallery/gallery password) and not protect the albums.
    everybody who wants vist your gallery should be connected and so, you don't have the problem.

    @ zenphoto team :
    I don't know how are supposed to work `printRandomImages()` and `printImageStatistic()` in that case (all albums are password protected, so no images are supposed to be shown)
  • Thanks Vincent!!!!!

    That code corrects all my problems. Index page loads fine now for not logged in viewer. And logging out is fast also.

    Unfortunately I can't write PHP or SQL code, just enough copy & paste, & search to be dangerous!

    FYI: printRandomImages() and printImageStatistic() does not show any images to not logged in viewers, it shows an empty box containing "Random images", so images are still protected.
  • vincent3569 Member, Translator
    according to, the excessive load time of `printRandomImages` is due to your all password protected albums.

    the function can't find any picture to shown.
    I don't have a look on the code of the function, but I'm sure that something goes wrong here.
  • acrylian Administrator, Developer
    All our official functions should never show unpublished and/or protected items to anyone not having the rights to.
  • Well, the function to get the images will keep trying until it collects the desired number. I think it is probably a bug that `printRandomImages` does not quit if no random image is found. Then at least you would look at all images only once, not for as many times as you wanted random images.

    But really, printing random images when the viewer is not allowed to see anything does not make sense, so Vincent's change would be needed anyway.
  • vincent3569 Member, Translator
    I am not sure to understand if you want to do some modification in core or not :-s
    as told before, have protected album and want to show pictures (random, latest,...) is a non sense.
    but I think taht zenphoto should be "protected" from very long sql query that occur in that case...
  • acrylian Administrator, Developer
    What Stephen probably means is that if the gallery is protected completely anyway the query should not happen at all -> the function call not be made. Besides that the function maybe needs some improvement.
  • Thanks so much to everyone for the time it to look into this. ZP and zpArdoise are great efforts & I truly appreciate your efforts.

    I am an ex-professional photographer, and also have worked in advertising, and design so even though my gallery is only family photos I am very picky about the design & user experience of my gallery. The Tag Cloud and Random photos are great features for a family gallery, that lead people to old memories that they may forgotten. Everyone loves these features.

    These are features that I would never have dreamed of when I started the gallery 12 years ago, and just used html and css to design. My extended family loves what I have created.

    I suppose my distinct set of demands leads me to settings that end up breaking the software (sorry about that!) but really may not be used by many others.

    So my hats off to all 3 of you. You do fabulous work. And thanks for the great support!
Sign In or Register to comment.