Skip to content

Commit

Permalink
Merge branch 'master' into PHRAS-3960-clean-user-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat authored Apr 29, 2024
2 parents ebffb25 + 4540b28 commit 98705be
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 59 deletions.
16 changes: 8 additions & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ PHRASEANET_CACHE_HOST=redis
# @run
PHRASEANET_CACHE_PORT=6379

# PHP session management
# PHP session management : this must be related to the SESSION_SAVE_HANDLER parameter. type can be redis, file or native
# @run
PHRASEANET_SESSION_TYPE=redis
# @run
Expand Down 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
2 changes: 1 addition & 1 deletion docker/phraseanet/php.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ session.gc_divisor = 1000
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 1440
session.gc_maxlifetime = $PHRASEANET_USER_SESSION_LIFETIME

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
Expand Down
17 changes: 6 additions & 11 deletions docker/phraseanet/setup/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,16 @@ if [[ -f "$FILE" && $PHRASEANET_SETUP = 1 ]]; then
fi

echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet setting session type"
echo `date +"%Y-%m-%d %H:%M:%S"` " - SESSION_SAVE_HANDLER is $SESSION_SAVE_HANDLER"

if [[ $SESSION_SAVE_HANDLER == file ]]; then
bin/setup system:config set main.session.type "$SESSION_SAVE_HANDLER"
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is $SESSION_SAVE_HANDLER"
elif [[ $SESSION_SAVE_HANDLER == redis ]]; then
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Redis : setting Host to $PHRASEANET_SESSION_TYPE"
bin/setup system:config set main.session.type $PHRASEANET_SESSION_TYPE
echo `date +"%Y-%m-%d %H:%M:%S"` " - PHRASEANET_SESSION_TYPE is $PHRASEANET_SESSION_TYPE"

bin/setup system:config set main.session.type "$PHRASEANET_SESSION_TYPE"

if [[ $PHRASEANET_SESSION_TYPE == redis ]]; then
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Redis : setting redis connexion parameters"
bin/setup system:config set main.session.options.host $PHRASEANET_SESSION_HOST
bin/setup system:config set main.session.options.port $PHRASEANET_SESSION_PORT
bin/setup system:config set main.session.options.namespace $PHRASEANET_HOSTNAME
bin/setup system:config set main.session.ttl $PHRASEANET_USER_SESSION_LIFETIME
else
bin/setup system:config set main.session.type "native"
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Native"
fi

## Phraseanet application Database setting
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
10 changes: 8 additions & 2 deletions lib/Alchemy/Phrasea/Core/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function getConfig()
return $this->parser->parse($this->loadFile($this->config));
}

if (null !== $this->cache) {
if (null !== $this->cache && is_array($this->cache)) {
return $this->cache;
}

Expand All @@ -151,7 +151,13 @@ public function getConfig()
));
}

return $this->cache = require $this->compiled;
$this->cache = require $this->compiled;

if (is_array($this->cache)) {
return $this->cache;
} else {
throw new RuntimeException('Configuration compiled error');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function setDefault($name)
*/
public function getConfig()
{
if (empty($this->cache)) {
if (empty($this->cache) || !is_array($this->cache)) {
throw new RuntimeException('Configuration is not set up.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ public function create($name, $type, $description, $applicationWebsite, User $cr

public function delete(ApiApplication $application)
{
// make sure all apiaccounts linked by apiApplication are also deleted
$accts = $this->om->getRepository('Phraseanet:ApiAccount')->findBy(['application' => $application]);

foreach ($accts as $account) {
// remove ApiOauthCodes before ApiAccount
$oauthCodes = $this->om->getRepository('Phraseanet:ApiOauthCode')->findByAccount($account);
foreach ($oauthCodes as $oauthCode) {
$this->om->remove($oauthCode);
}

$this->om->remove($account);
}

$deliveries = $this->om->getRepository('Phraseanet:WebhookEventDelivery')->findBy(['application' => $application]);

foreach ($deliveries as $delivery) {
$payloads = $this->om->getRepository('Phraseanet:WebhookEventPayload')->findBy(['delivery' => $delivery]);

foreach ($payloads as $payload) {
$this->om->remove($payload);
}

$this->om->remove($delivery);
}

$this->om->remove($application);
$this->om->flush();
}
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
Loading

0 comments on commit 98705be

Please sign in to comment.