LayoutRegionMediaDelete calls Media->Delete to delete link

Bug #1236000 reported by Dan Garner
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xibo
Fix Released
Undecided
Dan Garner

Bug Description

I found the the API Call LayoutRegionMediaDelete first removes the specified Media from the specified Region. But then it also tries to delete the Media from DB-table "lklayoutmedia".
But if the Media is also part for another Region the function call Media->Delete($mediaId) fails, and returns an error message. The calling party cannot differentiate whether the removal from the Region did fail already , or just the removal from DB-Tabel "lklayoutmedia".
Therefore I would expect that LayoutRegionMediaDelete() just removes the Media from the specified Region, not more.
For deleting a Media entirely there is already another API Call "LayoutRegionMediaDelete()" for that purpose.

Therefore I propose to delete the Line "if (!$media->Delete($mediaId)) return $this->Error($media->GetErrorNumber(), $media->GetErrorMessage());" from public function LayoutRegionMediaDelete()

Kind Regards
Bodo

Tags: api

Related branches

Revision history for this message
Dan Garner (dangarner) wrote :

It must delete the link record using the LKID provided - the API method actually doesn't have enough information to do this for stored media - it needs the LKID to be provided.

Changed in xibo:
assignee: nobody → Dan Garner (dangarner)
milestone: none → 1.5.2
status: New → Triaged
tags: added: api
Revision history for this message
Bodo Teichmann (bodote) wrote :

hm ,I don't understand you comment:
you say "It must delete the link record using the LKID provided "
yes but this is already done in
region.data.class in function RemoveMedia(): it calls function RemoveDbLink() who sends an
"DELETE FROM lklayoutmedia WHERE lklayoutmediaID = $lkid ";
the lkid is taken from the XML - Node from Table "layout", that is removed from the "layout" xml just before.
therefore I don't understand why you say:
"the API method actually doesn't have enough information to do this for stored media-it needs the LKID to be provided " ?

On the other hand :
I used LayoutRegionLibraryAdd to add an existing media to a region.
but there is currently no "LayoutRegionLibraryDelete" in the API , just the "LayoutRegionMediaDelete", which I tried to use then.

So do we actually need a new API function called "LayoutRegionLibraryDelete" which is exactly the same as LayoutRegionMediaDelete with the exception of the line
"if (!$media->Delete($mediaId))
            return $this->Error($media->GetErrorNumber(), $media->GetErrorMessage());"
which would be omitted for LayoutRegionLibraryDelete() ?

Revision history for this message
Dan Garner (dangarner) wrote :

The method is wrong - it is not good enough to have the media id because if the same media item is linked to a region timeline more than once - we will not know which one we are editing.

The API call must have the LKID provided.

It is also incorrect to delete the actual media file - that should be a separate call to LibraryDelete

Changed in xibo:
status: Triaged → Fix Committed
Dan Garner (dangarner)
Changed in xibo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.