Skip to content

Commit

Permalink
Merge branch 'master' into PHRAS-4045-error-get-in
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat authored Apr 29, 2024
2 parents 7e2643f + df780d9 commit 770e97b
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 43 deletions.
14 changes: 7 additions & 7 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -908,25 +908,25 @@ PHRASEANET_SSH_PRIVATE_KEY=
# --- ImageMagick default policy override setting ----------------------------------------------------------------------

# @run
IMAGEMAGICK_POLICY_VERSION=6
IMAGEMAGICK_POLICY_VERSION=7

# @run
IMAGEMAGICK_POLICY_WIDTH=16KP
IMAGEMAGICK_POLICY_WIDTH=48KP

# @run
IMAGEMAGICK_POLICY_HEIGHT=16KP
IMAGEMAGICK_POLICY_HEIGHT=48KPP

# @run
IMAGEMAGICK_POLICY_MAP=512MiB
IMAGEMAGICK_POLICY_MAP=2048MiB

# @run
IMAGEMAGICK_POLICY_MEMORY=256MiB
IMAGEMAGICK_POLICY_MEMORY=2048MiB

# @run
IMAGEMAGICK_POLICY_AREA=128MB
IMAGEMAGICK_POLICY_AREA=4096MB

# @run
IMAGEMAGICK_POLICY_DISK=1GiB
IMAGEMAGICK_POLICY_DISK=6GiB

# @run
IMAGEMAGICK_POLICY_TEMPORARY_PATH=/tmp
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.under-phrasea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:

phraseanet:
extra_hosts:
- api-auth.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- keycloak.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-databox.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-expose.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-uploader.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
Expand All @@ -29,7 +29,7 @@ services:

worker:
extra_hosts:
- api-auth.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- keycloak.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-databox.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-expose.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
- api-uploader.${PHRASEA_DOMAIN}:${PHRASEA_GATEWAY_IP}
Expand Down
32 changes: 22 additions & 10 deletions docker/phraseanet/worker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,39 @@ echo `date +"%Y-%m-%d %H:%M:%S"` " - chown app:app on cache/ repository"
# logs \
# www


if [ -d "plugins/" ];then
chown -R app:app plugins
echo `date +"%Y-%m-%d %H:%M:%S"` " - chown app:app on plugins/ repository"
fi

if [ -f /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml ]; then
if [ -f /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml ]; then
if [ ! -d $IMAGEMAGICK_POLICY_TEMPORARY_PATH ]; then
echo "$IMAGEMAGICK_POLICY_TEMPORARY_PATH does not exist lets create it"
mkdir -p $IMAGEMAGICK_POLICY_TEMPORARY_PATH
fi
sed -i "s/domain=\"resource\" name=\"memory\" value=\".*\"/domain=\"resource\" name=\"memory\" value=\"$IMAGEMAGICK_POLICY_MEMORY\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"map\" value=\".*\"/domain=\"resource\" name=\"map\" value=\"$IMAGEMAGICK_POLICY_MAP\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"width\" value=\".*\"/domain=\"resource\" name=\"width\" value=\"$IMAGEMAGICK_POLICY_WIDTH\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"height\" value=\".*\"/domain=\"resource\" name=\"height\" value=\"$IMAGEMAGICK_POLICY_HEIGHT\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"disk\" value=\".*\"/domain=\"resource\" name=\"disk\" value=\"$IMAGEMAGICK_POLICY_DISK\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"area\" value=\".*\"/domain=\"resource\" name=\"area\" value=\"$IMAGEMAGICK_POLICY_AREA\"/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/.*domain=\"resource\" name=\"temporary-path\" value=\".*/<domain=\"resource\" name=\"temporary-path\" value=\"\\$IMAGEMAGICK_POLICY_TEMPORARY_PATH\" \/\>/g" /etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"memory\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"memory\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"map\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"map\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"width\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"width\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"height\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"height\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"disk\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"disk\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"area\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"area\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"temporary-path\"/s/<!--//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i '/domain=\"resource\" name=\"temporary-path\"/s/-->//g' /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"memory\" value=\".*\"/domain=\"resource\" name=\"memory\" value=\"$IMAGEMAGICK_POLICY_MEMORY\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"map\" value=\".*\"/domain=\"resource\" name=\"map\" value=\"$IMAGEMAGICK_POLICY_MAP\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"width\" value=\".*\"/domain=\"resource\" name=\"width\" value=\"$IMAGEMAGICK_POLICY_WIDTH\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"height\" value=\".*\"/domain=\"resource\" name=\"height\" value=\"$IMAGEMAGICK_POLICY_HEIGHT\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"disk\" value=\".*\"/domain=\"resource\" name=\"disk\" value=\"$IMAGEMAGICK_POLICY_DISK\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/domain=\"resource\" name=\"area\" value=\".*\"/domain=\"resource\" name=\"area\" value=\"$IMAGEMAGICK_POLICY_AREA\"/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
sed -i "s/.*domain=\"resource\" name=\"temporary-path\" value=\".*/<domain=\"resource\" name=\"temporary-path\" value=\"\\$IMAGEMAGICK_POLICY_TEMPORARY_PATH\" \/\>/g" /usr/local/etc/ImageMagick-$IMAGEMAGICK_POLICY_VERSION/policy.xml
fi


if [[ $NEWRELIC_ENABLED = "true" ]]; then
echo `date +"%Y-%m-%d %H:%M:%S"` " - NewRelic daemon and PHP agent setup."
sed -i -e "s/REPLACE_WITH_REAL_KEY/$NEWRELIC_LICENSE_KEY/" \
Expand Down
5 changes: 1 addition & 4 deletions lib/Alchemy/Phrasea/Cache/RedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ public function deleteMulti(array $keys)

public function removeByPattern($pattern)
{
$keysToremove = [];
$iterator = null;
while(false !== ($keys = $this->_redis->scan($iterator, $pattern))) {
$keysToremove = array_merge($keysToremove, $keys);
$this->_redis->del($keys);
}

$this->_redis->del($keysToremove);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function process(WebhookEvent $event)
$record = $this->findDataboxById($data['databox_id'])->get_record($data['record_id']);
$subdef = $record->get_subdef($data['subdef_name']);

if (empty($data['permalink'])) {
if (empty($data['permalink']) && $subdef->get_permalink() !== null) {
$data['permalink'] = $subdef->get_permalink()->get_url()->__toString();
}

Expand Down
17 changes: 12 additions & 5 deletions lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function process(array $payload)
$databox = $record->getDatabox();
$caption = $record->get_caption();
$lat = $lng = null;
$webVTT = '';
$webVTT = [];

if (in_array($payload['databoxId'], $sendGeolocField)) {
$latFieldName = $lonFieldName = '';
Expand Down Expand Up @@ -189,12 +189,19 @@ public function process(array $payload)

if (in_array($payload['databoxId'], $sendVttField)) {
foreach ($databox->get_meta_structure() as $meta) {
if (strpos(strtolower($meta->get_name()), strtolower('VideoTextTrack')) !== FALSE && $caption->has_field($meta->get_name())) {
if (1 === preg_match('#^VideoTextTrack([a-z]{2}(?:[-_]\w+)?)#i', $meta->get_name(), $matches) && $caption->has_field($meta->get_name())) {
// retrieve value for the corresponding field
$fieldValues = $record->get_caption()->get_field($meta->get_name())->get_values();
$fieldValue = array_pop($fieldValues);

$webVTT .= "\n\n" .$fieldValue->getValue();
$locale = strtolower($matches[1]);
$content = trim($fieldValue->getValue());

$webVTT[] = [
'id' => md5($content),
'locale' => $locale,
'label' => $locale,
'content' => $content,
];
}
}
}
Expand Down Expand Up @@ -248,7 +255,7 @@ public function process(array $payload)
$requestBody['lng'] = $lng;
}

if ($webVTT !== '') {
if (!empty($webVTT)) {
$requestBody['webVTT'] = $webVTT;
}

Expand Down
20 changes: 15 additions & 5 deletions lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function __construct(Application $app)
public function process(array $payload)
{
if (isset($payload['id'])) {
$webhookEventId = $payload['id'];

/** @var WebhookEvent|null $webhookevent */
$webhookevent = $this->app['repo.webhook-event']->find($webhookEventId);
$wData = $webhookevent->getData();

$this->repoWorkerJob = $this->getWorkerRunningJobRepository();
$em = $this->repoWorkerJob->getEntityManager();
$em->beginTransaction();
Expand All @@ -70,12 +76,20 @@ public function process(array $payload)
$workerRunningJob = new WorkerRunningJob();
$workerRunningJob
->setWork(MessagePublisher::WEBHOOK_TYPE)
->setWorkOn('WebhookEventId: '. $payload['id'])
->setWorkOn($webhookevent->getName() . ' , WebhookEventId: '. $payload['id'])
->setPayload($message)
->setPublished($date->setTimestamp($payload['published']))
->setStatus(WorkerRunningJob::RUNNING)
;

if (isset($wData['databox_id'])) {
$workerRunningJob->setDataboxId($wData['databox_id']);
}

if (isset($wData['record_id'])) {
$workerRunningJob->setRecordId($wData['record_id']);
}

$em->persist($workerRunningJob);

$em->flush();
Expand All @@ -85,7 +99,6 @@ public function process(array $payload)
$em->rollback();
}

$webhookEventId = $payload['id'];
$app = $this->app;

$version = new Version();
Expand All @@ -107,9 +120,6 @@ public function process(array $payload)

$thirdPartyApplications = $this->app['repo.api-applications']->findWithDefinedWebhookCallback();

/** @var WebhookEvent|null $webhookevent */
$webhookevent = $this->app['repo.webhook-event']->find($webhookEventId);

if ($webhookevent !== null) {
$app['manipulator.webhook-event']->processed($webhookevent);

Expand Down
6 changes: 3 additions & 3 deletions resources/locales/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,9 @@
<target state="translated">Zurück zur Sammelkörbe Liste</target>
<jms:reference-file line="8">WorkZone/Browser/Basket.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color">
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color" xml:space="preserve">
<source>Background Color</source>
<target state="translated">Hintergrundfarbe</target>
<target state="needs-translation">Hintergrundfarbe (z.B: #FFFFFF)</target>
<jms:reference-file line="45">Media/Subdef/Image.php</jms:reference-file>
</trans-unit>
<trans-unit id="ae1378dc6a6f7df2435c398db9e6eac71646092b" resname="Bad request format, only JSON is allowed" approved="yes">
Expand Down Expand Up @@ -9862,7 +9862,7 @@
</trans-unit>
<trans-unit id="2564f949b4f742e02863e1fcc205df91774c51f9" resname="admin::workermanager:tab:workerinfo: change status to canceled" xml:space="preserve">
<source>admin::workermanager:tab:workerinfo: change status to canceled</source>
<target state="needs-translation">Als "abbrechen" markieren</target>
<target state="needs-translation">Die gestartete Jobs als "Abbrechen" markieren, die seit...</target>
<jms:reference-file line="7">admin/worker-manager/worker_info.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="224add9949a95aa2f40517f6f74ad86e4a76e376" resname="admin::workermanager:tab:workerinfo: created" approved="yes">
Expand Down
6 changes: 3 additions & 3 deletions resources/locales/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,9 @@
<target state="translated">Back to baskets list</target>
<jms:reference-file line="8">WorkZone/Browser/Basket.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color">
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color" xml:space="preserve">
<source>Background Color</source>
<target state="translated">Background color</target>
<target state="needs-translation">Background color (ex: #FFFFFF)</target>
<jms:reference-file line="45">Media/Subdef/Image.php</jms:reference-file>
</trans-unit>
<trans-unit id="ae1378dc6a6f7df2435c398db9e6eac71646092b" resname="Bad request format, only JSON is allowed" approved="yes">
Expand Down Expand Up @@ -9864,7 +9864,7 @@
</trans-unit>
<trans-unit id="2564f949b4f742e02863e1fcc205df91774c51f9" resname="admin::workermanager:tab:workerinfo: change status to canceled" xml:space="preserve">
<source>admin::workermanager:tab:workerinfo: change status to canceled</source>
<target state="needs-translation">Mark as "cancel"</target>
<target state="needs-translation">Mark as "Cancel" the jobs started since...</target>
<jms:reference-file line="7">admin/worker-manager/worker_info.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="224add9949a95aa2f40517f6f74ad86e4a76e376" resname="admin::workermanager:tab:workerinfo: created" approved="yes">
Expand Down
6 changes: 3 additions & 3 deletions resources/locales/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,9 @@
<target state="translated">Retour à la liste des paniers</target>
<jms:reference-file line="8">WorkZone/Browser/Basket.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color">
<trans-unit id="874df4e774343ace22071f648b6b67d11e21b307" resname="Background Color" xml:space="preserve">
<source>Background Color</source>
<target state="translated">Couleur de fond</target>
<target state="needs-translation">Couleur de fond (ex: #FFFFFF)</target>
<jms:reference-file line="45">Media/Subdef/Image.php</jms:reference-file>
</trans-unit>
<trans-unit id="ae1378dc6a6f7df2435c398db9e6eac71646092b" resname="Bad request format, only JSON is allowed" approved="yes">
Expand Down Expand Up @@ -9863,7 +9863,7 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le
</trans-unit>
<trans-unit id="2564f949b4f742e02863e1fcc205df91774c51f9" resname="admin::workermanager:tab:workerinfo: change status to canceled" xml:space="preserve">
<source>admin::workermanager:tab:workerinfo: change status to canceled</source>
<target state="needs-translation">Marquer "Annuler"</target>
<target state="needs-translation">Marquer "Annuler" les travaux démarrés depuis...</target>
<jms:reference-file line="7">admin/worker-manager/worker_info.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="224add9949a95aa2f40517f6f74ad86e4a76e376" resname="admin::workermanager:tab:workerinfo: created" approved="yes">
Expand Down

0 comments on commit 770e97b

Please sign in to comment.