Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gautiermichelin/6e8fa124bf5fafd7a9f6 to your computer and use it in GitHub Desktop.
Save gautiermichelin/6e8fa124bf5fafd7a9f6 to your computer and use it in GitHub Desktop.
CollectiveAccess : detection & reprocessing of media not treated by queue (either for access permission or format error)
<?php
require_once('setup.php');
require_once('app/models/ca_object_representations.php');
require_once('app/lib/core/Db.php');
$o_data = new Db();
$qr_reps = $o_data->query("
SELECT *
FROM ca_object_representations
");
$t_rep = new ca_object_representations();
$t_rep->setMode(ACCESS_WRITE);
$i=0;
$num_being_processed=0;
$first=true;
// Detection empty
// print "./bin/caUtils reprocess-media --ids ";
while($qr_reps->nextRow()) {
$va_media_info = $qr_reps->getMediaInfo('media');
$i++;
$being_processed=null;
$representation_id=$qr_reps->get('representation_id');
$representation = new ca_object_representations($representation_id);
//if($representation->mediaIsEmpty() == false) print "(".$i.") ".$representation_id." media empty\n";
$representations = $representation->getRepresentations();
$preview170 = $representations[0][tags][preview170];
if ($preview170 == "L'image est en cours de traitement.") {
$num_being_processed++;
$being_processed=true;
};
if ($being_processed) {
//if (!$first) print ",";
//print $representation_id;
$first=false;
$t_rep->load($qr_reps->get('representation_id'));
$t_rep->set('media', $qr_reps->getMediaPath('media', 'original'), array('original_filename' => $vs_original_filename));
$t_rep->update();
if ($t_rep->numErrors()) {
print("Error processing representation media: %1". join('; ', $t_rep->getErrors())."<br/>\n");
} else {
print "Media retraité ".$representation_id."<br/>\n";
}
$i++;
}
//if($i==10) exit();
}
print "<br/>\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment