<?php $start = microtime(true); set_time_limit(0); require_once dirname(__FILE__) . '/../../alpha/config/sfrootdir.php'; // check cache before loading anything require_once "../lib/KalturaResponseCacher.php"; $cache = new KalturaResponseCacher(null, "/web/cache/feed/", 86400); $cache->checkOrStart(); require_once "../bootstrap.php"; KalturaLog::setContext("syndicationFeedRenderer"); KalturaLog::debug(">------------------------------------- syndicationFeedRenderer -------------------------------------"); KalturaLog::info("syndicationFeedRenderer-start "); $feedId = $_GET['feedId']; $entryId = @$_GET['entryId']; try { $syndicationFeedRenderer = new KalturaSyndicationFeedRenderer($feedId); $syndicationFeedRenderer->addFlavorParamsAttachedFilter(); if (isset($entryId)) { $syndicationFeedRenderer->addEntryAttachedFilter($entryId); } $syndicationFeedRenderer->execute(); } catch (Exception $ex) { header('KalturaSyndication: ' . $ex->getMessage()); die; } $end = microtime(true); KalturaLog::info("syndicationFeedRenderer-end [" . ($end - $start) . "]"); KalturaLog::debug("<------------------------------------- syndicationFeedRenderer -------------------------------------"); $cache->end();
$limit = getRequestParameter('limit'); $ks = getRequestParameter('ks'); $feedProcessingKey = "feedProcessing_{$feedId}_{$entryId}_{$limit}"; if (function_exists('apc_fetch')) { if (apc_fetch($feedProcessingKey)) { KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST); } } try { $syndicationFeedRenderer = new KalturaSyndicationFeedRenderer($feedId, $feedProcessingKey, $ks); $syndicationFeedRenderer->addFlavorParamsAttachedFilter(); kCurrentContext::$partner_id = $syndicationFeedRenderer->syndicationFeed->partnerId; if (isset($entryId)) { $syndicationFeedRenderer->addEntryAttachedFilter($entryId); } $syndicationFeedRenderer->execute($limit); } catch (PropelException $pex) { KalturaLog::alert($pex->getMessage()); KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST, 'KalturaSyndication: Database error'); } catch (Exception $ex) { KalturaLog::err($ex->getMessage()); $msg = 'KalturaSyndication: ' . str_replace(array("\n", "\r"), array("\t", ''), $ex->getMessage()); KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST, $msg); } //in KalturaSyndicationFeedRenderer - if the limit does restrict the amount of entries - the entries counter passes the limit's value by one , so it must be decreased back $entriesCount = $syndicationFeedRenderer->getReturnedEntriesCount(); $entriesCount--; setCacheExpiry($entriesCount, $feedId); $end = microtime(true); KalturaLog::info("syndicationFeedRenderer-end [" . ($end - $start) . "] memory: " . memory_get_peak_usage(true)); KalturaLog::debug("<------------------------------------- syndicationFeedRenderer -------------------------------------");