Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Close session on possibly long requests that may block the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jan 18, 2017
1 parent 5908f02 commit 120aaf9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/plugins/action.share/src/ShareCenter.php
Expand Up @@ -840,6 +840,7 @@ public function switchAction(ServerRequestInterface &$requestInterface, Response

case "load_shared_element_data":

SessionService::close();
$node = null;
if(isSet($httpVars["hash"]) && $httpVars["element_type"] == "file"){

Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/core.conf/AbstractConfDriver.php
Expand Up @@ -1276,6 +1276,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI

case "load_repository_info":

SessionService::close();
$data = [];
$repo = $ctx->getRepository();
if($repo != null){
Expand Down
6 changes: 6 additions & 0 deletions core/src/plugins/core.notifications/IFeedStore.php
Expand Up @@ -92,6 +92,12 @@ public function loadAlerts($userObject, $repositoryIdFilter = null);
*/
public function dismissAlertById(ContextInterface $ctx, $alertId, $occurrences = 1);

/**
* @param ContextInterface $ctx
* @param $objectId
*/
public function dismissMetaObjectById(ContextInterface $ctx, $objectId);

/**
* @param string $indexPath
* @param mixed $data
Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/core.notifications/NotificationCenter.php
Expand Up @@ -32,6 +32,7 @@
use Pydio\Core\Controller\Controller;
use Pydio\Core\Services\LocaleService;
use Pydio\Core\Services\RepositoryService;
use Pydio\Core\Services\SessionService;
use Pydio\Core\Utils\Vars\InputFilter;
use Pydio\Core\Utils\Vars\StatHelper;
use Pydio\Core\PluginFramework\Plugin;
Expand Down Expand Up @@ -201,6 +202,7 @@ public function loadRepositoryInfo(ContextInterface $ctx, &$data){
*/
public function loadUserFeed(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface, &$returnData = [])
{
SessionService::close();
$httpVars = $requestInterface->getParsedBody();
if(!$this->eventStore) {
throw new \Pydio\Core\Exception\PydioException("Cannot find eventStore for notification plugin");
Expand Down
14 changes: 14 additions & 0 deletions core/src/plugins/feed.sql/SqlFeedStore.php
Expand Up @@ -401,11 +401,25 @@ public function findMetaObjectsByIndexPath($repositoryId, $indexPath, $userId, $
return $data;
}

/**
* @inheritdoc
*/
public function dismissMetaObjectById(ContextInterface $ctx, $objectId){
if(!dibi::isConnected()) {
dibi::connect($this->sqlDriver);
}
$userId = $ctx->getUser()->getId();
$userGroup = $ctx->getUser()->getGroupPath();
dibi::query("DELETE FROM [ajxp_feed] WHERE [id] = %i AND ([user_id] = %s OR [user_group] = %s) AND [etype] = %s", $objectId, $userId, $userGroup, "meta");
}


/**
* @param $repositoryId
* @param $oldPath
* @param null $newPath
* @param bool $copy
* @return mixed|void
*/
public function updateMetaObject($repositoryId, $oldPath, $newPath = null, $copy = false)
{
Expand Down
4 changes: 3 additions & 1 deletion core/src/plugins/meta.comments/CommentsMetaManager.php
Expand Up @@ -24,6 +24,7 @@
use Pydio\Access\Core\Model\UserSelection;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\LocaleService;
use Pydio\Core\Services\SessionService;
use Pydio\Core\Utils\Vars\InputFilter;
use Pydio\Core\Utils\Vars\StatHelper;

Expand Down Expand Up @@ -174,6 +175,7 @@ public function switchActions($actionName, $httpVars, $fileVars, ContextInterfac

case "load_comments_feed":

SessionService::close();
HTMLWriter::charsetHeader("application/json");
if ($feedStore !== false) {
$sortBy = isSet($httpVars["sort_by"])? InputFilter::decodeSecureMagic($httpVars["sort_by"]) :"date";
Expand Down Expand Up @@ -242,7 +244,7 @@ public function switchActions($actionName, $httpVars, $fileVars, ContextInterfac
HTMLWriter::charsetHeader("application/json");
echo json_encode($reFeed);
} else {
$feedStore->dismissAlertById($ctx, $data["uuid"], 1);
$feedStore->dismissMetaObjectById($ctx, $data["uuid"]);
}

break;
Expand Down

0 comments on commit 120aaf9

Please sign in to comment.