3131use OCP \WorkflowEngine \IManager ;
3232use OCP \WorkflowEngine \IRuleMatcher ;
3333use OCP \WorkflowEngine \ISpecificOperation ;
34+ use Psr \Log \LoggerInterface ;
3435use RuntimeException ;
3536use UnexpectedValueException ;
3637
3738class Operation implements ISpecificOperation, IComplexOperation {
39+ protected array $ issuedTagNotFoundWarnings = [];
40+
3841 public function __construct (
3942 protected readonly ISystemTagObjectMapper $ objectMapper ,
4043 protected readonly ISystemTagManager $ tagManager ,
@@ -46,7 +49,8 @@ public function __construct(
4649 protected readonly IRootFolder $ rootFolder ,
4750 protected readonly File $ fileEntity ,
4851 protected readonly IUserSession $ userSession ,
49- protected readonly IGroupManager $ groupManager
52+ protected readonly IGroupManager $ groupManager ,
53+ protected readonly LoggerInterface $ logger ,
5054 ) {
5155 }
5256
@@ -64,7 +68,19 @@ public function checkOperations(IStorage $storage, int $fileId, string $file): v
6468 $ matches = $ matcher ->getFlows (false );
6569
6670 foreach ($ matches as $ match ) {
67- $ this ->objectMapper ->assignTags ((string ) $ fileId , 'files ' , explode (', ' , $ match ['operation ' ]));
71+ try {
72+ $ this ->objectMapper ->assignTags ((string )$ fileId , 'files ' , explode (', ' , $ match ['operation ' ]));
73+ } catch (TagNotFoundException $ e ) {
74+ $ msg = sprintf ('The tag to assign (ID %s) cannot be found anymore. The related rule is %s. ' ,
75+ $ match ['operation ' ],
76+ $ match ['scope_type ' ] === 0 ? 'global ' : 'owned by ' . $ match ['scope_actor_id ' ]
77+ );
78+ if (isset ($ this ->issuedTagNotFoundWarnings [md5 ($ msg )])) {
79+ continue ;
80+ }
81+ $ this ->issuedTagNotFoundWarnings [md5 ($ msg )] = true ;
82+ $ this ->logger ->error ($ msg );
83+ }
6884 }
6985 }
7086
0 commit comments