Changeset 935

Show
Ignore:
Timestamp:
10/06/05 18:45:17 (3 years ago)
Author:
mbonetti
Message:

fix for pruned items still appearing in the feed count

Location:
trunk/rss
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/rss/admin/items.php

    r856 r935  
    158158                //echo "\n\n"; 
    159159                 
    160                 if (count($cids)) { 
     160                if (count($cids)) { 
    161161                    // Righto. Lets check which of these ids still is in cache: 
    162162 
     
    166166                    // extract all the urls for each cached item, keep them sorted 
    167167                    // by feed 
    168                     foreach($curls as $cid => $curl) { 
    169                         //$rss = $cache->get($curl .  MAGPIE_OUTPUT_ENCODING); 
    170                         // suppress warnings because Magpie is rather noisy 
    171                         $old_level = error_reporting(E_ERROR); 
    172                         $rss = fetch_rss( $curl ); 
    173                         //reset 
    174                         error_reporting($old_level); 
    175  
    176                         $cacheUrls[$cid]= array(); 
    177                         //echo "Feed: $cid\n"; 
    178                         if ($rss) { 
    179                           foreach($rss->items as $item) { 
    180                             // this comes from util.php:update() 
    181  
    182                             if (array_key_exists('link',$item) && $item['link'] != "") { 
    183                                $url = $item['link']; 
    184                             } elseif (array_key_exists('guid',$item) && $item['guid'] != "") { 
    185                                $url = $item['guid']; 
    186                             } else { 
    187                                // fall back to something basic 
    188                                $url =  md5($item['title']); 
    189                             } 
    190                             $cacheUrls[$cid][] = htmlentities($url); 
    191                             //echo "in cache: $url\n"; 
    192                           } 
    193                         } 
    194                     } 
     168                        foreach($curls as $cid => $curl) { 
     169                            // suppress warnings because Magpie is rather noisy 
     170              $old_level = error_reporting(E_ERROR); 
     171                $rss = fetch_rss( $curl ); 
     172                //reset 
     173                error_reporting($old_level); 
     174 
     175              $cacheUrls[$cid]= array(); 
     176              //echo "Feed: $cid\n"; 
     177              if ($rss) { 
     178                foreach($rss->items as $item) { 
     179                                    // this comes from util.php:update() 
     180     
     181                                    if (array_key_exists('link',$item) && $item['link'] != "") { 
     182                                        $url = $item['link']; 
     183                                    } elseif (array_key_exists('guid',$item) && $item['guid'] != "") { 
     184                                        $url = $item['guid']; 
     185                                    } else { 
     186                                        // fall back to something basic 
     187                                        $url =  md5($item['title']); 
     188                                    } 
     189                                    $cacheUrls[$cid][] = htmlentities($url); 
     190                                } 
     191              } 
     192                        } 
    195193                     
    196194 
    197                   // now, sort the ids to be deleted into two lists: in chache / to trash 
    198                   $in_cache = array(); 
    199                   $to_trash = array(); 
    200                   //var_dump($cacheUrls); 
    201                   foreach ($cids as $cid => $ids) { 
    202                         foreach ($ids as $arr) { 
    203                             list($iid,$iurl) = $arr; 
    204                             //echo "examining: $iid (cid $cid) -> $iurl ->"; 
    205                             if (array_search($iurl, $cacheUrls[$cid]) !== FALSE) { 
    206                                 $in_cache[] = $iid; 
    207                                 //echo " in cache!\n"; 
    208                             } else { 
    209                                 $to_trash[] = $iid; 
    210                                 //echo " not in cache!\n"; 
    211                             } 
    212                         } 
    213                   } 
     195                    // now, sort the ids to be deleted into two lists: in chache / to trash 
     196                    $in_cache = array(); 
     197                    $to_trash = array(); 
     198                    //var_dump($cacheUrls); 
     199                    foreach ($cids as $cid => $ids) { 
     200                                foreach ($ids as $arr) { 
     201                                        list($iid,$iurl) = $arr; 
     202                                        //echo "examining: $iid (cid $cid) -> $iurl ->"; 
     203                                        if (array_search($iurl, $cacheUrls[$cid]) !== FALSE) { 
     204                                                $in_cache[] = $iid; 
     205                                                //echo " in cache!\n"; 
     206                                        } else { 
     207                                                $to_trash[] = $iid; 
     208                                                //echo " not in cache!\n"; 
     209                                        } 
     210                                } 
     211                    } 
    214212                    
    215                   // cheers, we're set. Now delete the metatag links for *all* 
    216                   // items to be deleted 
     213                    // cheers, we're set. Now delete the metatag links for *all* 
     214                    // items to be deleted 
    217215                    if (count($ids)) { 
    218216                        $sqldel = "delete from " .getTable('metatag') . " where fid in (" 
     
    229227                        ); 
    230228                    } 
    231                     if (count($in_cache)) { 
     229            if (count($in_cache)) { 
    232230                        rss_query( "update " . getTable('item') 
    233231                         ." set unread = unread | " . FEED_MODE_DELETED_STATE 
     
    238236                        ); 
    239237                    } 
    240                 } 
     238         } 
    241239                $ret__ = CST_ADMIN_DOMAIN_ITEM; 
    242240                 
  • trunk/rss/cls/channels.php

    r893 r935  
    163163 
    164164        _pf(' ... totalCount');      
    165         $res = rss_query("select count(*) from ".getTable("item") 
    166             ." where not(unread & ".FEED_MODE_DELETED_STATE.") " 
    167             . (hidePrivate()? " and not(unread & ".FEED_MODE_PRIVATE_STATE.")":"") 
     165        $sql =  
     166        "select count(*) from ".getTable("item") . "i , " . getTable('channels') . " c " 
    168167             
    169             ); 
     168            ." where i.cid=c.id and not(i.unread & ".FEED_MODE_DELETED_STATE.") " 
     169            ." and not (c.mode & " .FEED_MODE_DELETED_STATE.")" 
     170            . (hidePrivate()? " and not(unread & ".FEED_MODE_PRIVATE_STATE.")":""); 
    170171             
    171              
     172            //echo $sql; 
     173            $res = rss_query($sql); 
    172174        list ($total) = rss_fetch_row($res); 
    173175        _pf(' ... done: totalCount');