From 2445a72f85fa57bbb224502ebd6b158234988e1e Mon Sep 17 00:00:00 2001 From: Shahbaa Shalan Date: Thu, 7 Nov 2024 13:25:09 +0200 Subject: [PATCH 1/4] SUP-39240 FIXED Redirected queries to Elasticsearch instead of Sphinx for dynamic playlists when entitlement enforcement is enabled. --- .../kaltura/lib/myPlaylistUtils.class.php | 48 ++++++++----------- api_v3/services/PlaylistService.php | 15 ++++-- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php index cf0cd204b9e..87a2b495c05 100644 --- a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php +++ b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php @@ -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; } @@ -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; } diff --git a/api_v3/services/PlaylistService.php b/api_v3/services/PlaylistService.php index ead4c5cea2a..f87e3916d3d 100644 --- a/api_v3/services/PlaylistService.php +++ b/api_v3/services/PlaylistService.php @@ -344,7 +344,7 @@ function executeAction( $id , $detailed = false, KalturaContext $playlistContext if (is_null($detailed)) $detailed = true ; - if($filter || kEntitlementUtils::getEntitlementEnforcement()) + if($filter) { try { @@ -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()); } } @@ -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; @@ -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) @@ -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; } From 20bf0d7ba0c7d621cb2b02bfbfc84089a2522a93 Mon Sep 17 00:00:00 2001 From: shahbaa123 <129391094+shahbaa123@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:22:56 +0200 Subject: [PATCH 2/4] Update myPlaylistUtils.class.php fixed indentation --- alpha/apps/kaltura/lib/myPlaylistUtils.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php index 87a2b495c05..f4e83f74007 100644 --- a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php +++ b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php @@ -206,7 +206,7 @@ public static function executePlaylist ($partner_id , $playlist , $filter = null break; case PlaylistType::STATIC_LIST: case PlaylistType::PATH: - $entryIdListStr = $playlist->getDataContent(); + $entryIdListStr = $playlist->getDataContent(); $entryObjectsArray = self::executeStaticPlaylistFromEntryIdsString($entryIdListStr, $filter, $detailed, $pager, $playlist->getEntryId()); default: break; @@ -348,7 +348,7 @@ public static function executeStaticPlaylistFromEntryIdsString($entryIdListStr, } } - return null; + return null; } /** From fa109df2a1a103914c3d074325a84a334e4ead4f Mon Sep 17 00:00:00 2001 From: shahbaa123 <129391094+shahbaa123@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:28:49 +0200 Subject: [PATCH 3/4] Update myPlaylistUtils.class.php fixed indentation --- .../kaltura/lib/myPlaylistUtils.class.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php index f4e83f74007..4876479925f 100644 --- a/alpha/apps/kaltura/lib/myPlaylistUtils.class.php +++ b/alpha/apps/kaltura/lib/myPlaylistUtils.class.php @@ -328,27 +328,27 @@ public static function getStaticPlaylistFilters(entry $playlist) return array($filter); } - public static function executeStaticPlaylistFromEntryIdsString($entryIdListStr, $filter = null, $detailed = true, $pager = null, $playlistId = null) + public static function executeStaticPlaylistFromEntryIdsString($entryIdListStr, $filter = null, $detailed = true, $pager = null, $playlistId = null) { - $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; + $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; } /** From f691cf2daf490fb7473df699afccd5b1761f46bf Mon Sep 17 00:00:00 2001 From: shahbaa123 <129391094+shahbaa123@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:30:18 +0200 Subject: [PATCH 4/4] Update PlaylistService.php fixed indentation --- api_v3/services/PlaylistService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api_v3/services/PlaylistService.php b/api_v3/services/PlaylistService.php index f87e3916d3d..e919b3f5ff8 100644 --- a/api_v3/services/PlaylistService.php +++ b/api_v3/services/PlaylistService.php @@ -383,11 +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); - } + { + return $this->executeFromContentLogic($playlistType, $playlistContent, $detailed, $pager); + } - function executeFromContentLogic($playlistType, $playlistContent, $detailed = false, $pager = null, $playlistId = null) + 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;