Created
April 16, 2012 15:58
-
-
Save timglabisch/2399647 to your computer and use it in GitHub Desktop.
pimcore download all revisions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// now you can use $args ... | |
include_once(__DIR__."/../../pimcore/cli/startup.php"); | |
Pimcore_Version::$revision = 10; | |
$updates = Pimcore_Update::getAvailableUpdates(); | |
$buffer = array(); | |
// get all possible updates | |
foreach(array_merge($updates['revisions'], $updates['releases']) as $k => $v) { | |
if(isset($buffer[$v['id']])) | |
throw new \Exception('multiple revisions with id '. $v['id']); | |
} | |
ksort($buffer); | |
$archiv = new ZipArchive(); | |
if(!$archiv->open(PIMCORE_SYSTEM_TEMP_DIRECTORY.'/update.zip', ZIPARCHIVE::CREATE)) | |
die('cant create update.zip'); | |
foreach($buffer as $revision => $v) { | |
echo 'download Revision '.$revision."\n"; | |
$xml = Pimcore_Tool::getHttpData('http://update.pimcore.org/v2/getFiles.php?for='.$revision.'&offset=0&limit=50'); | |
if($xml) | |
$archiv->addFromString('getFiles-'.$revision, $xml); | |
$xml = Pimcore_Tool::getHttpData('http://update.pimcore.org/v2/getUpdateFiles.php?for='.$revision); | |
if($xml) | |
$archiv->addFromString('getUpdateFiles-'.$revision, $xml); | |
} | |
$archiv->close(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once(__DIR__."/../../pimcore/cli/startup.php"); | |
#Pimcore_Version::$revision = 951; | |
function pimcore_update_downloadData ($revision, $url) { | |
/* just change this lines */ | |
if(class_exists('Pimcore_Resource')) | |
$db = Pimcore_Resource::get(); | |
else | |
$db = Pimcore_Resource_Mysql::get(); | |
$db->query("CREATE TABLE IF NOT EXISTS `" . Pimcore_Update::$tmpTable . "` ( | |
`revision` int(11) NULL DEFAULT NULL, | |
`path` varchar(255) NULL DEFAULT NULL, | |
`action` varchar(50) NULL DEFAULT NULL | |
);"); | |
$downloadDir = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update/".$revision; | |
if(!is_dir($downloadDir)) { | |
mkdir($downloadDir,0755,true); | |
} | |
$filesDir = $downloadDir . "/files"; | |
if(!is_dir($filesDir)) { | |
mkdir($filesDir,0755,true); | |
} | |
$scriptsDir = $downloadDir . "/scripts"; | |
if(!is_dir($scriptsDir)) { | |
mkdir($scriptsDir,0755,true); | |
} | |
$xml = file_get_contents($url); // just changed this line!! | |
if($xml) { | |
$updateFiles = simplexml_load_string($xml, null, LIBXML_NOCDATA); | |
foreach ($updateFiles->file as $file) { | |
if($file->type == "file") { | |
if ($file->action == "update" || $file->action == "add") { | |
$newPath = str_replace("/","~~~",$file->path); | |
$newFile = $filesDir."/".$newPath; | |
file_put_contents($newFile, base64_decode((string) $file->content)); | |
chmod($newFile, 0766); | |
} | |
$db->insert(Pimcore_Update::$tmpTable, array( | |
"revision" => $revision, | |
"path" => (string) $file->path, | |
"action" => (string)$file->action | |
)); | |
} else if ($file->type == "script") { | |
$newScript = $scriptsDir. $file->path; | |
file_put_contents($newScript, base64_decode((string) $file->content)); | |
chmod($newScript, 0766); | |
} | |
} | |
} | |
} | |
// test if current script is worker. | |
if(!isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2]) || $_SERVER['argv'][1] != '--revision') { | |
for($i = Pimcore_Version::$revision; $i <= 1810; $i++) { | |
passthru('php '.escapeshellarg(__FILE__).' --revision '. escapeshellarg($i)); | |
echo "\n"; | |
ob_flush(); | |
} | |
die(); | |
} | |
$revision = $_SERVER['argv'][2]; | |
chdir(PIMCORE_SYSTEM_TEMP_DIRECTORY); | |
pimcore_update_downloadData($revision, 'zip://update.zip#getFiles-'.$revision); | |
pimcore_update_downloadData($revision, 'zip://update.zip#getUpdateFiles-'.$revision); | |
// download data | |
Pimcore_Update::executeScript($revision, "preupdate"); | |
Pimcore_Update::installData($revision); | |
Pimcore_Update::executeScript($revision, "postupdate"); | |
//Pimcore_Update::downloadLanguage(); doesnt work offline | |
Pimcore_Model_Cache::clearAll(); | |
Pimcore_Update::cleanup(); | |
echo 'install revision '.$revision; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment