Skip to content

Commit

Permalink
Merge pull request #8625 from kaltura/Orion-15.1.0-creationDateUpdate…
Browse files Browse the repository at this point in the history
…Script

Orion 15.1.0 creation date update script
  • Loading branch information
hilak committed Jul 8, 2019
2 parents bb183c6 + be9a148 commit dddc3f3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions alpha/lib/model/entry.php
Expand Up @@ -1843,6 +1843,9 @@ public function getSourceEntryId() { return $this->getFromCustomData( "sourceE
public function setReachedMaxRecordingDuration ( $v ) { $this->putInCustomData ( "reachedMaxRecordingDuration" , (bool) $v ); }
public function getReachedMaxRecordingDuration() { return (bool) $this->getFromCustomData( "reachedMaxRecordingDuration" ,null, false ); }

public function setOriginalCreationDate ( $v ) { $this->putInCustomData ( "originalCreationDate" , $v); }
public function getOriginalCreationDate() { return $this->getFromCustomData( "originalCreationDate", null, null); }


public function getParentEntry()
{
Expand Down
41 changes: 41 additions & 0 deletions alpha/scripts/utils/setEntryCreationDate.php
@@ -0,0 +1,41 @@
<?php

if($argc < 3)
{
echo "Arguments missing.\n\n";
echo "Usage: php " . __FILE__ . " {mapping} {isDateString} <realrun / dryrun> \n";
exit;
}
$mapping = $argv[1];
$isDateString = ($argv[2] === "true");
$dryRun = ($argv[3] === "dryrun");

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

KalturaStatement::setDryRun($dryRun);

$entryMappings = file($mapping, FILE_IGNORE_NEW_LINES);

$counter = 0;
foreach ($entryMappings as $entryMapping)
{
list ($entryId,$createdAt) = explode(",", $entryMapping);
$createdAt = $isDateString ? strtotime($createdAt) : $createdAt;

$entry = entryPeer::retrieveByPK($entryId);
if(!$entry)
{
echo "Entry id [$entryId] not found\n";
continue;
}

$entry->setOriginalCreationDate($entry->getCreatedAt());
$entry->setCreatedAt($createdAt);
$entry->setAvailableFrom($createdAt);
$entry->save();

kEventsManager::flushEvents();
kMemoryManager::clearMemory();
}

KalturaLog::debug('Done');

0 comments on commit dddc3f3

Please sign in to comment.