<commit_before><commit_msg>Add migration script and pull up the whole code to conform to Jupiter-10-11.0 Jupiter-10.7.0-UDRM_and_cEnc #time 1 hour<commit_after><?php
ini_set("memory_limit","1024M");

chdir(__DIR__.'/../');
require_once(__DIR__ . '/../bootstrap.php');

class kAccessControlPlayReadyPolicyAction extends kRuleAction
{
    protected $policyId;

    public function __construct()
    {
        parent::__construct(DrmAccessControlActionType::DRM_POLICY);
    }
    public function getPolicyId()
    {
        return $this->policyId;
    }
    public function setPolicyId($policyId)
    {
        $this->policyId = $policyId;
    }
}

$permCrit = new Criteria();
$permCrit->add(PermissionPeer::NAME, 'PLAYREADY_PLUGIN_PERMISSION', Criteria::EQUAL);
$permCrit->addAnd(PermissionPeer::STATUS, 1, Criteria::EQUAL);
$permissions = PermissionPeer::doSelect($permCrit);
$partners = array();
foreach ($permissions as $perm)
{
    $partners[] = $perm->getPartnerId();
}

KalturaLog::debug("Partners are '".print_r($partners,true)."'");

$c = new Criteria();
$c->add(accessControlPeer::PARTNER_ID, $partners, Criteria::IN);
$c->addAnd(accessControlPeer::RULES, '%kAccessControlPlayReadyPolicyAction%', Criteria::LIKE);//This is the correct line
$acs = accessControlPeer::doSelect($c);
foreach ($acs as $ac)
{
    KalturaLog::debug("checking access control '".$ac->getId()."'");
    $rules = $ac->getRulesArray();
    foreach ($rules as $rule)
    {
        $actions = $rule->getActions();
        $j = 0;
        foreach ($actions as $action)
        {
            KalturaLog::debug("checking action '".print_r($action,true)."'");
            if (get_class($action) == 'kAccessControlPlayReadyPolicyAction')//This is the correct line
            {
                KalturaLog::debug("replacing kAccessControlPlayReadyPolicyAction with kAccessControlDrmPolicyAction");
                $newAction = new kAccessControlDrmPolicyAction();//This is the correct line
                $newAction->setPolicyId($action->getPolicyId());
                $actions[$j] = $newAction;
                $rule->setActions($actions);
                $ac->setRulesArray($rules);
                $ac->save();
                KalturaLog::debug("finished saving");
            }
            $j++;
        }
    }
}

{'fraction_non_alphanumeric': 0.1518324607329843, 'fraction_numerical': 0.006980802792321117, 'mean_word_length': 3.3264150943396227, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6889637', 'n_tokens_mistral': 715, 'n_tokens_neox': 686, 'n_words': 130}