Created
November 16, 2017 11:38
-
-
Save Opencontent/73611a3a77d5cc3bca0d04bcde896ebd to your computer and use it in GitHub Desktop.
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 | |
require 'autoload.php'; | |
$script = eZScript::instance( array( 'description' => ( 'Download images from endpoint' ), | |
'use-session' => false, | |
'use-modules' => true, | |
'use-extensions' => true ) ); | |
$script->startup(); | |
$options = $script->getOptions( '[url:][vardir:]', | |
'', | |
array( | |
'url' => 'Endpoint url', | |
'vardir' => 'Remote var directory (eg ezflow_site)' | |
) | |
); | |
$script->initialize(); | |
$script->setUseDebugAccumulators( true ); | |
$cli = eZCLI::instance(); | |
$output = new ezcConsoleOutput(); | |
$query = "SELECT distinct ezcontentobject_version.contentobject_id, COUNT( * ) as qtd FROM ezcontentobject_version WHERE ezcontentobject_version.status = 1 GROUP BY ezcontentobject_version.contentobject_id HAVING count(*) > 1;"; | |
$res = eZDB::instance()->arrayQuery($query); | |
$objectIdList = array(); | |
foreach ($res as $row) { | |
$objectIdList[] = $row['contentobject_id']; | |
} | |
foreach ($objectIdList as $objectId) { | |
$query = "SELECT * FROM ezcontentobject_version WHERE contentobject_id = {$objectId} AND status = 1 ORDER BY modified ASC"; | |
$versions = eZDB::instance()->arrayQuery($query); | |
$object = eZContentObject::fetch($objectId); | |
if ($object instanceof eZContentObject){ | |
$cli->warning($object->attribute('name'), false); | |
$current = $object->attribute('current_version'); | |
$cli->warning(" (versione corrente $current)"); | |
if (count($versions) > 1){ | |
foreach ($versions as $version) { | |
if($version['version'] != $current){ | |
$versionVersion = $version['version']; | |
$query = "UPDATE ezcontentobject_version SET status = 3 WHERE version = {$versionVersion} AND contentobject_id = {$objectId}"; | |
$cli->notice('Archivio versione ' . $versionVersion); | |
eZDB::instance()->arrayQuery($query); | |
} | |
} | |
} | |
}else{ | |
$cli->error("Oggetto non trovato $objectId"); | |
} | |
} | |
$script->shutdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copiare in document root di un solo nodo del cluster e lanciare con:
php fix_multi_published_version.php -s001admin