Type conversion error in Storage tab

35 views
Skip to first unread message

Steffan Ravn Edwardsen

unread,
Nov 30, 2015, 8:44:37 AM11/30/15
to munkireport-dev
Hi all,

First of all: Thanks for the great work you've put into this project, I love working with MunkiReport and it is a great tool for showing off to the head of the department. ;)

I noticed something strange in my environment though; under the client-view in the Storage-tab it showed that ALL drives where encrypted and that ALL drives where internal - which is certainly not the case, so I started digging into the code.
It seems to be a type conversion error/issue in assets/js/munkireport.storageplot.js, where the properties obj.CoreStorageEncrypted and obj.Internal actually returns strings and not integers as expected, even though they are defined as integers in the database. The result is that these expressions:

37:   var encrypted = obj.CoreStorageEncrypted ? i18n.t('storage.encrypted') : i18n.t('storage.not_encrypted');
and
60:   val: obj.Internal ? i18n.t('storage.internal') : i18n.t('storage.external')

are always true and thus always returns the first options (i.e. always "Encrypted" and always "Internal").

I corrected the issue by parsing the properties as integers with parseInt(), but maybe it's some JSON/PHP encoding/decoding problem somewhere else.

Is anybody else experiencing this behavior?

As the system is somewhat complex, I'm not certain where the issue arose, so maybe it should be corrected in a completely different place?

I am currently running:
MunkiReport version 2.6.1.1487 on a Ubuntu 14.04.3 Server with PHP 5.5.9, MySQL Server 5.5.44 and Apache 2.4.7.

I'm accessing the web interface via Safari 9.0.1 or Firefox 42.0.

Hope you'll chime in with some input.

Sincerely
Steffan

A.E. van Bochoven

unread,
Nov 30, 2015, 12:08:38 PM11/30/15
to munkire...@googlegroups.com
Hi Steffan,

I can't reproduce your issue (although I'm running the latest wip). As you've probably seen the data comes from a json response to


the response should look like:

[{"id":237203,"serial_number":"SERIAL_NUMBER","TotalSize":"119722213376","FreeSpace":"90194313216","Percentage":25,"SMARTStatus":"Verified","VolumeType":"ssd","BusProtocol":"PCI","Internal":1,"MountPoint":"\/","VolumeName":"Macintosh HD","CoreStorageEncrypted":1,"timestamp":1448898608}]

where CoreStorageEncrypted and Internal both are integers.

-Arjen



--
You received this message because you are subscribed to the Google Groups "munkireport-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to munkireport-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steffan Ravn Edwardsen

unread,
Dec 1, 2015, 3:39:20 AM12/1/15
to munkireport-dev
Hi Arjen, thank you for responding so swiftly.

That is indeed odd, when I try to get the data, my JSON-array response data is all strings, even id, Percentage and timestamp:

[{"id":"12661","serial_number":"SERIAL_NUMBER","TotalSize":"498753077248","FreeSpace":"457950887936","Percentage":"8","SMARTStatus":"Verified","VolumeType":"ssd","BusProtocol":"PCI","Internal":"1","MountPoint":"\/","VolumeName":"Macintosh HD","CoreStorageEncrypted":"0","timestamp":"1448900002"}]

I googled around an saw other people experiencing similar things, where database integers gets returned as strings, I did not find a definitive answer, but it seems to be a question of the database driver:

Is there anything else you want me to test or try out? It sounds like people are experiencing different behavior, depending on OS and versions of PHP and MySQL - or even bugs in the json_encode function.

Sincerely
Steffan

Steffan Ravn Edwardsen

unread,
Jan 4, 2016, 5:15:08 AM1/4/16
to munkireport-dev
Hi, sorry to bump this thread, but I would really appreciate if anyone has any ideas on what I can try to solve this?

Sincerely
Steffan

A.E. van Bochoven

unread,
Jan 9, 2016, 10:58:59 AM1/9/16
to munkire...@googlegroups.com
Hi Steffan,

Could you open an issue for this? I think we may need to force the type of the database fields here:


although it's strange that no other people are having this issue.

-Arjen

Steffan Ravn Edwardsen

unread,
Jan 11, 2016, 5:16:31 AM1/11/16
to munkireport-dev
Hi Arjen,

Thanks for the feedback, I'll open an issue, but I agree - it's strange, I didn't see the problem in my initial test-setup either.

/Steffan
Reply all
Reply to author
Forward
0 new messages