xibosignage / xibo

Xibo Digital Signage
https://xibosignage.com
GNU Affero General Public License v3.0
573 stars 164 forks source link

LayoutRegionMediaAdd - Passing XML with a Media ID Causing "ID does not match" error #22

Closed MichaelHoughton closed 9 years ago

MichaelHoughton commented 9 years ago

I am attempting to upload the following XML via the LayoutRegionMediaAdd method in the API.

The XML is for an image, as below:

<!--?xml version="1.0"?-->
<layout width="800" height="450" bgcolor="#000000" schemaversion="1"><region name="asfasdasd" id="54bd569e74009" userid="1" width="800" height="450" top="0" left="0"><media id="122" type="image" duration="10" lkid="73" userid="1" schemaversion="1">
<options><uri>122.jpg</uri></options>
<raw>
</raw></media></region></layout>

However, I get an error when posting this. The error says "ID does not match".

I debugged the code, and found the following:

Line 1958 of lib/modules/module.class.php has the following:

// We already know that the media id exists, now check it matches
if ($mediaNode->getAttribute('id') != $this->mediaid)
    return $this->SetError(__('ID does not match'));

The problem, as far as I can tell, is that the $this->mediaid variable is never defined in the API, so it is blank.

This problem exists on version 1.6 as well.

dasgarner commented 9 years ago

That sounds like a bug, ill tag it up and look at it for you tomorrow.

dasgarner commented 9 years ago

Hi Michael,

I think that the ValidateMediaXml method that you arrived at by debugging is not quite right. Instead of checking to see if the mediaId matches the one assigned to the Module, it should check that the mediaId exists in the library and if so, make the assignment to the module itself.

I've made that modification and will attach the commit in a moment - can you try it?

MichaelHoughton commented 9 years ago

Sure thing! Please let me know when the commit is in, and I will give this a whirl!

dasgarner commented 9 years ago

OK, she is there - its in my development fork, release/1.7.0 branch (I guess you can see/pull that)

MichaelHoughton commented 9 years ago

Yep, I can! I will keep you posted.

MichaelHoughton commented 9 years ago

Hey Dan - just need to see if we can get this one solved: https://github.com/xibosignage/xibo/issues/24

Then I can test out this API!