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

Commit 2cd6990

Browse files
committed
Fix event on change error when cross-repository copy.
1 parent 9cde874 commit 2cd6990

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,36 @@ public function persistChangeHookToFeed(AJXP_Node $oldNode = null, AJXP_Node $ne
9595
{
9696
if(!$this->eventStore) return;
9797

98-
$n = ($oldNode == null ? $newNode : $oldNode);
99-
$repoId = $n->getRepositoryId();
100-
if($n->getUser()){
101-
$userId = $n->getUser();
102-
$obj = ConfService::getConfStorageImpl()->createUserObject($userId);
103-
if($obj) $userGroup = $obj->getGroupPath();
98+
$nodes = [];
99+
if($oldNode !== null && $newNode !== null && $oldNode->getRepositoryId() !== $newNode->getRepositoryId()){
100+
$nodes[] = $oldNode;
101+
$nodes[] = $newNode;
104102
}else{
105-
$userId = AuthService::getLoggedUser()->getId();
106-
$userGroup = AuthService::getLoggedUser()->getGroupPath();
103+
$nodes[] = ($oldNode === null ? $newNode : $oldNode);
104+
}
105+
106+
foreach($nodes as $n){
107+
$repoId = $n->getRepositoryId();
108+
$userGroup = null;
109+
if($n->getUser()){
110+
$userId = $n->getUser();
111+
$obj = ConfService::getConfStorageImpl()->createUserObject($userId);
112+
if($obj) $userGroup = $obj->getGroupPath();
113+
}else{
114+
$userId = AuthService::getLoggedUser()->getId();
115+
$userGroup = AuthService::getLoggedUser()->getGroupPath();
116+
}
117+
$repository = ConfService::getRepositoryById($repoId);
118+
$repositoryScope = $repository->securityScope();
119+
$repositoryScope = ($repositoryScope !== false ? $repositoryScope : "ALL");
120+
$repositoryOwner = $repository->hasOwner() ? $repository->getOwner() : null;
121+
AJXP_Controller::applyHook("msg.instant",array(
122+
"<reload_user_feed/>",
123+
$repoId,
124+
$userId
125+
));
126+
$this->eventStore->persistEvent("node.change", func_get_args(), $repoId, $repositoryScope, $repositoryOwner, $userId, $userGroup);
107127
}
108-
$repository = ConfService::getRepositoryById($repoId);
109-
$repositoryScope = $repository->securityScope();
110-
$repositoryScope = ($repositoryScope !== false ? $repositoryScope : "ALL");
111-
$repositoryOwner = $repository->hasOwner() ? $repository->getOwner() : null;
112-
AJXP_Controller::applyHook("msg.instant",array(
113-
"<reload_user_feed/>",
114-
$repoId,
115-
$userId
116-
));
117-
$this->eventStore->persistEvent("node.change", func_get_args(), $repoId, $repositoryScope, $repositoryOwner, $userId, $userGroup);
118128

119129
}
120130

core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ public function persistEvent($hookName, $data, $repositoryId, $repositoryScope,
6464
}
6565
try {
6666
$node = null;
67-
if(is_object($data[1]) && is_a($data[1], "AJXP_Node")) $node = $data[1];
68-
else if(is_object($data[0]) && is_a($data[0], "AJXP_Node")) $node = $data[0];
67+
if(is_object($data[1]) && $data[1] instanceof AJXP_Node && $data[1]->getRepositoryId() === $repositoryId) {
68+
$node = $data[1];
69+
} else if(is_object($data[0]) && $data[0] instanceof AJXP_Node && $data[0]->getRepositoryId() === $repositoryId) {
70+
$node = $data[0];
71+
}
6972
dibi::query("INSERT INTO [ajxp_feed] ([edate],[etype],[htype],[user_id],[repository_id],[repository_owner],[user_group],[repository_scope],[content],[index_path]) VALUES (%i,%s,%s,%s,%s,%s,%s,%s,%bin,%s)",
7073
time(),
7174
"event",

0 commit comments

Comments
 (0)