Skip to content

Commit

Permalink
Merge pull request #12965 from kaltura/Ursa-21.3.0-SUP-39240
Browse files Browse the repository at this point in the history
SUP-39240 FIXED Redirected queries to Elasticsearch instead of Sphinx…
  • Loading branch information
shahbaa123 authored Nov 19, 2024
2 parents 58af13c + f691cf2 commit 5b82181
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
48 changes: 20 additions & 28 deletions alpha/apps/kaltura/lib/myPlaylistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ public static function executePlaylist ($partner_id , $playlist , $filter = null
break;
case PlaylistType::STATIC_LIST:
case PlaylistType::PATH:
$entryObjectsArray = self::executeStaticPlaylist ( $playlist , $filter , $detailed, $pager );
$entryIdListStr = $playlist->getDataContent();
$entryObjectsArray = self::executeStaticPlaylistFromEntryIdsString($entryIdListStr, $filter, $detailed, $pager, $playlist->getEntryId());
default:
break;
}
Expand Down Expand Up @@ -326,35 +327,26 @@ public static function getStaticPlaylistFilters(entry $playlist)

return array($filter);
}

public static function executeStaticPlaylist ( entry $playlist , $filter = null, $detailed = true, $pager = null )
{
$entry_id_list_str = $playlist->getDataContent();
if(kEntitlementUtils::getEntitlementEnforcement() &&
kCurrentContext::$ks_object &&
kCurrentContext::$ks_object->getDisableEntitlementForPlaylistPlaylistId() === $playlist->getEntryId())
{
kEntitlementUtils::initEntitlementEnforcement(null, false);
entryPeer::setDefaultCriteriaFilter();
$result = self::executeStaticPlaylistFromEntryIdsString($entry_id_list_str, $filter, $detailed, $pager);
kEntitlementUtils::initEntitlementEnforcement();
entryPeer::setDefaultCriteriaFilter();
}
else
{
$result = self::executeStaticPlaylistFromEntryIdsString($entry_id_list_str, $filter, $detailed, $pager);
}

return $result;
}

public static function executeStaticPlaylistFromEntryIdsString($entry_id_list_str, $filter = null, $detailed = true, $pager = null)
public static function executeStaticPlaylistFromEntryIdsString($entryIdListStr, $filter = null, $detailed = true, $pager = null, $playlistId = null)
{
$entry_id_list = self::getEntryIdsFromStaticPlaylistString($entry_id_list_str);
if($entry_id_list)
{
return self::executeStaticPlaylistFromEntryIds($entry_id_list, $filter, $detailed, $pager);
}
$entryIdList = self::getEntryIdsFromStaticPlaylistString($entryIdListStr);
if($entryIdList)
{
if(kEntitlementUtils::getEntitlementEnforcement() && kCurrentContext::$ks_object && kCurrentContext::$ks_object->getDisableEntitlementForPlaylistPlaylistId() === $playlistId)
{
kEntitlementUtils::initEntitlementEnforcement(null, false);
entryPeer::setDefaultCriteriaFilter();
$result = self::executeStaticPlaylistFromEntryIds($entryIdList, $filter, $detailed, $pager);
kEntitlementUtils::initEntitlementEnforcement();
entryPeer::setDefaultCriteriaFilter();
return $result;
}
else
{
return self::executeStaticPlaylistFromEntryIds($entryIdList, $filter, $detailed, $pager);
}
}

return null;
}
Expand Down
15 changes: 10 additions & 5 deletions api_v3/services/PlaylistService.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function executeAction( $id , $detailed = false, KalturaContext $playlistContext
if (is_null($detailed))
$detailed = true ;

if($filter || kEntitlementUtils::getEntitlementEnforcement())
if($filter)
{
try
{
Expand All @@ -366,7 +366,7 @@ function executeAction( $id , $detailed = false, KalturaContext $playlistContext
$tempPlaylist->playlistContent = "";

$tempPlaylist->playlistType = $playlist->getMediaType();
return $this->executeFromContentAction($tempPlaylist->playlistType, $tempPlaylist->playlistContent, $detailed, $pager);
return $this->executeFromContentLogic($tempPlaylist->playlistType, $tempPlaylist->playlistContent, $detailed, $pager, $playlist->getEntryId());
}
}

Expand All @@ -383,6 +383,11 @@ function executeAction( $id , $detailed = false, KalturaContext $playlistContext
* @return KalturaBaseEntryArray
*/
function executeFromContentAction($playlistType, $playlistContent, $detailed = false, $pager = null)
{
return $this->executeFromContentLogic($playlistType, $playlistContent, $detailed, $pager);
}

function executeFromContentLogic($playlistType, $playlistContent, $detailed = false, $pager = null, $playlistId = null)
{
$partnerId = $this->getPartnerId() ? $this->getPartnerId() : kCurrentContext::getCurrentPartnerId();
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
Expand All @@ -392,13 +397,13 @@ function executeFromContentAction($playlistType, $playlistContent, $detailed = f
}
list($entryFiltersViaEsearch, $entryFiltersViaSphinx, $totalResults) = myPlaylistUtils::splitEntryFilters($playlistContent);
$pagerSeparateQueries = self::decideWhereHandlingPager($pager,$entryFiltersViaEsearch, $entryFiltersViaSphinx);
$entryList = self::handlePlaylistByType($playlistType, $entryFiltersViaEsearch, $entryFiltersViaSphinx, $partnerId, $pagerSeparateQueries, $pager, $totalResults, $playlistContent);
$entryList = self::handlePlaylistByType($playlistType, $entryFiltersViaEsearch, $entryFiltersViaSphinx, $partnerId, $pagerSeparateQueries, $pager, $totalResults, $playlistContent, $playlistId);
myEntryUtils::updatePuserIdsForEntries($entryList);
KalturaLog::debug("entry ids count: " . (is_array($entryList ? count($entryList) : 0)));
return KalturaBaseEntryArray::fromDbArray($entryList, $this->getResponseProfile());
}

protected static function handlePlaylistByType($playlistType, $entryFiltersViaEsearch, $entryFiltersViaSphinx, $partnerId, $pagerSeperateQueries, $pager, $totalResults, $playlistContent)
protected static function handlePlaylistByType($playlistType, $entryFiltersViaEsearch, $entryFiltersViaSphinx, $partnerId, $pagerSeperateQueries, $pager, $totalResults, $playlistContent, $playlistId = null)
{
$entryList = null;
switch($playlistType)
Expand All @@ -408,7 +413,7 @@ protected static function handlePlaylistByType($playlistType, $entryFiltersViaEs
break;
case KalturaPlaylistType::STATIC_LIST:
case KalturaPlaylistType::PATH:
$entryList = myPlaylistUtils::executeStaticPlaylistFromEntryIdsString($playlistContent, null, true, $pager);
$entryList = myPlaylistUtils::executeStaticPlaylistFromEntryIdsString($playlistContent, null, true, $pager, $playlistId);
break;
}

Expand Down

0 comments on commit 5b82181

Please sign in to comment.