SimplePie_Cache_DB

Base class for database-based caches.

Defined (1)

The class is defined in the following location(s).

/wp-includes/SimplePie/Cache/DB.php  
  1. abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base 
  2. /** 
  3. * Helper for database conversion 
  4. * Converts a given {@see SimplePie} object into data to be stored 
  5. * @param SimplePie $data 
  6. * @return array First item is the serialized data for storage, second item is the unique ID for this item 
  7. */ 
  8. protected static function prepare_simplepie_object_for_cache($data) 
  9. $items = $data->get_items(); 
  10. $items_by_id = array(); 
  11.  
  12. if (!empty($items)) 
  13. foreach ($items as $item) 
  14. $items_by_id[$item->get_id()] = $item; 
  15.  
  16. if (count($items_by_id) !== count($items)) 
  17. $items_by_id = array(); 
  18. foreach ($items as $item) 
  19. $items_by_id[$item->get_id(true)] = $item; 
  20.  
  21. if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) 
  22. $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; 
  23. elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) 
  24. $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; 
  25. elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) 
  26. $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; 
  27. elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) 
  28. $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; 
  29. else 
  30. $channel = null; 
  31.  
  32. if ($channel !== null) 
  33. if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) 
  34. unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); 
  35. if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) 
  36. unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); 
  37. if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) 
  38. unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); 
  39. if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) 
  40. unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); 
  41. if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) 
  42. unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); 
  43. if (isset($data->data['items'])) 
  44. unset($data->data['items']); 
  45. if (isset($data->data['ordered_items'])) 
  46. unset($data->data['ordered_items']); 
  47. return array(serialize($data->data), $items_by_id);