@@ -102,9 +102,17 @@ public function getStack(int $stackId): Stack {
102102 * @param string $name resource name like card-123.ics, deck-card-123.ics or stack-12.ics
103103 * @return Card|Stack|null
104104 */
105- public function findCalendarObjectByName (string $ name , ?int $ boardId = null , ?int $ stackId = null ) {
105+ public function findCalendarObjectByName (string $ name , ?int $ boardId = null , ?int $ stackId = null , bool $ includeDeleted = true ) {
106106 if (preg_match ('/^(?:deck-)?card-(\d+)\.ics$/ ' , $ name , $ matches ) === 1 ) {
107- $ card = $ this ->findCardByIdIncludingDeleted ((int )$ matches [1 ]);
107+ $ cardId = (int )$ matches [1 ];
108+ $ card = null ;
109+ try {
110+ $ card = $ includeDeleted
111+ ? $ this ->findCardByIdIncludingDeleted ($ cardId )
112+ : $ this ->cardService ->find ($ cardId );
113+ } catch (\Throwable $ e ) {
114+ $ card = null ;
115+ }
108116 if ($ card === null ) {
109117 return null ;
110118 }
@@ -296,7 +304,7 @@ public function updateCalendarObject($sourceItem, string $data) {
296304 /**
297305 * @param Card|Stack $sourceItem
298306 */
299- public function deleteCalendarObject ($ sourceItem , ?int $ expectedBoardId = null ): void {
307+ public function deleteCalendarObject ($ sourceItem , ?int $ expectedBoardId = null , ? int $ expectedStackId = null ): void {
300308 if ($ sourceItem instanceof Card) {
301309 $ currentCard = $ sourceItem ;
302310 if ($ expectedBoardId !== null ) {
@@ -307,6 +315,10 @@ public function deleteCalendarObject($sourceItem, ?int $expectedBoardId = null):
307315 // Ignore trailing delete from source calendar after a cross-board move.
308316 return ;
309317 }
318+ if ($ expectedStackId !== null && $ currentCard ->getStackId () !== $ expectedStackId ) {
319+ // Ignore trailing delete from source list calendar after an in-board move.
320+ return ;
321+ }
310322 } catch (\Throwable $ e ) {
311323 // If we cannot resolve the current card, continue with normal delete behavior.
312324 }
0 commit comments