diff --git a/.env b/.env index f07a86b58a..43bde72aa3 100644 --- a/.env +++ b/.env @@ -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 diff --git a/docker/phraseanet/php.ini.sample b/docker/phraseanet/php.ini.sample index f122f8ce15..a4c714dc60 100644 --- a/docker/phraseanet/php.ini.sample +++ b/docker/phraseanet/php.ini.sample @@ -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* diff --git a/docker/phraseanet/setup/entrypoint.sh b/docker/phraseanet/setup/entrypoint.sh index 7fb412c193..8abaad59c7 100755 --- a/docker/phraseanet/setup/entrypoint.sh +++ b/docker/phraseanet/setup/entrypoint.sh @@ -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 diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php index 5a2d4a7008..0e3f4cc8a4 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php @@ -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(); }