Ignore:
Timestamp:
Nov 4, 2010, 1:42:14 AM (13 years ago)
Author:
grum
Message:

fix bug:2004 - Cache table becomes very huge
fix bug:2005 - Category map is not displayed when a [gmaps] map is inserted in category description

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/gmaps_root.class.inc.php

    r7547 r7616  
    8585      $this->section_name=$this->getPluginNameFiles();
    8686
    87       $this->setTablesList(array('maps', 'category_maps', 'cache', 'kmlfiles'));
     87      $this->setTablesList(array('maps', 'category_maps', 'cache', 'cache_id', 'kmlfiles'));
    8888      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    8989    }
     
    312312    }
    313313
     314
     315    /**
     316     * returns a new requestId for the cache
     317     */
     318    protected function getCacheRequestId()
     319    {
     320      global $user;
     321
     322      $returned=0;
     323
     324      // new requestId
     325      $sql="INSERT INTO ".$this->tables['cache_id']."
     326            VALUES ('', '".$user['id']."', '".date('Y-m-d h:i:s')."');";
     327      $result=pwg_query($sql);
     328      if($result)
     329      {
     330        $returned=pwg_db_insert_id();
     331      }
     332
     333      return($returned);
     334    }
     335
     336    /**
     337     * update date for a cache requestId
     338     */
     339    protected function updateCacheRequestId($requestId)
     340    {
     341      global $user;
     342
     343      // new requestId
     344      $sql="UPDATE ".$this->tables['cache_id']."
     345            SET `date` = '".date('Y-m-d h:i:s')."'
     346            WHERE requestId='$requestId';";
     347      pwg_query($sql);
     348    }
     349
     350    /**
     351     * clean the cache : cache values older than given number of second are
     352     * deleted
     353     *
     354     * @param Integer $time : number of second
     355     */
     356    protected function cleanCache($time=300)
     357    {
     358      $date=date('Y-m-d h:i:s', time()-$time);
     359
     360      $sql="DELETE FROM ".$this->tables['cache']." pgc
     361              USING ".$this->tables['cache']." pgc
     362                JOIN ".$this->tables['cache_id']." pgci
     363                ON pgc.requestId = pgci.requestId
     364            WHERE pgci.`date` < '$date';";
     365      pwg_query($sql);
     366
     367      $sql="DELETE FROM ".$this->tables['cache_id']."
     368            WHERE `date` < '$date';";
     369      pwg_query($sql);
     370    }
     371
    314372  } //class
    315373
Note: See TracChangeset for help on using the changeset viewer.