Changeset 112419 in spip-zone for _plugins_/mailsubscribers


Ignore:
Timestamp:
Nov 14, 2018, 4:17:30 PM (5 weeks ago)
Author:
root
Message:

optimisations rapidite : eviter de recalculer N fois les informations liees d'un subscriber si on actualise les N segments d'une meme liste

Location:
_plugins_/mailsubscribers/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/mailsubscribers/trunk/inc/mailsubscribinglists.php

    r109223 r112419  
    7575                                or in_array($id_segment, $update_needed)
    7676                          or (isset($segment['auto_update']) and $segment['auto_update'])){
    77                                 mailsubscribers_actualise_segment($id_mailsubscriber, $id_mailsubscribinglist, $id_segment);
     77                                mailsubscribers_actualise_segment($id_mailsubscriber, $id_mailsubscribinglist, $id_segment, $segments[$id_mailsubscribinglist]);
    7878                        }
    7979                }
     
    8787 * @param $id_mailsubscribinglist
    8888 * @param $id_segment
     89 * @param array $segments
    8990 */
    90 function mailsubscribers_actualise_segment($id_mailsubscriber, $id_mailsubscribinglist, $id_segment){
    91         static $segments = array();
    92         if (!isset($segments[$id_mailsubscribinglist])) {
    93                 if ($segments[$id_mailsubscribinglist] = sql_getfetsel('segments','spip_mailsubscribinglists','id_mailsubscribinglist='.intval($id_mailsubscribinglist))){
    94                         $segments[$id_mailsubscribinglist] = unserialize($segments[$id_mailsubscribinglist]);
     91function mailsubscribers_actualise_segment($id_mailsubscriber, $id_mailsubscribinglist, $id_segment, $segments = null){
     92        if (is_null($segments)) {
     93                if ($segments = sql_getfetsel('segments','spip_mailsubscribinglists','id_mailsubscribinglist='.intval($id_mailsubscribinglist))){
     94                        $segments = unserialize($segments);
    9595                }
    9696        }
    9797
    98         if (isset($segments[$id_mailsubscribinglist][$id_segment])){
    99                 $need = mailsubscribers_teste_segment($id_mailsubscriber,$segments[$id_mailsubscribinglist][$id_segment]);
     98        if ($segments and isset($segments[$id_segment])){
     99                $need = mailsubscribers_teste_segment($id_mailsubscriber,$segments[$id_segment]);
    100100                $where = 'id_mailsubscriber='.intval($id_mailsubscriber).' AND id_mailsubscribinglist='.intval($id_mailsubscribinglist).' AND id_segment=';
    101101                $is = sql_countsel('spip_mailsubscriptions', $where . intval($id_segment));
     
    119119 */
    120120function mailsubscribers_teste_segment($id_mailsubscriber, $segment){
     121        static $informations_liees = array();
    121122        static $declaration;
    122123        if (is_null($declaration)){
     
    129130        if (!$declaration) return false;
    130131
    131         $email = sql_getfetsel('email','spip_mailsubscribers','id_mailsubscriber='.intval($id_mailsubscriber));
    132         $infos = mailsubscriber_recuperer_informations_liees($id_mailsubscriber, $email);
     132        if (!isset($informations_liees[$id_mailsubscriber])) {
     133                $email = sql_getfetsel('email','spip_mailsubscribers','id_mailsubscriber='.intval($id_mailsubscriber));
     134                $informations_liees[$id_mailsubscriber] = mailsubscriber_recuperer_informations_liees($id_mailsubscriber, $email);
     135        }
     136        $infos = &$informations_liees[$id_mailsubscriber];
    133137
    134138        foreach($segment as $k=>$v){
  • _plugins_/mailsubscribers/trunk/paquet.xml

    r112111 r112419  
    22        prefix="mailsubscribers"
    33        categorie="communication"
    4         version="2.9.4"
     4        version="2.9.5"
    55        etat="stable"
    66        compatibilite="[3.0.0;3.2.*]"
Note: See TracChangeset for help on using the changeset viewer.