Ticket #6378 (closed defect: fixed)
PHP web API return wrong value(s) when only a single machine is present on host
|Reported by:||Sm0k1n||Owned by:|
|Version:||VirtualBox 3.1.4||Keywords:||php, collection, constructor|
If only one virtual machine is present on the host, some calls to the php web api like IVirtualBox->machines should return an array of machines, but since there is only one machine, only one object is returned. It seems that either there is a bug in the api itself or PHP tries to be smart and does not create an array with only one object. Either way, the constructor of the collection object requires an array and it fails to get one, therefore this error comes up:
Argument 2 passed to VBox_ManagedObjectCollection::__construct() must be an array, string given
This is also the case with IVirtualBox->DVDImage when only one dvd image is present. Having more than one machine/dvd/etc. solves the issue.
System info ---- VirtualBox: 3.1.2, 3.1.4 (bug is present in both versions) Host: openSuse 11.2 Kernel: 220.127.116.11-0.1-default PHP: 5.3.1 Web Server: Apache 2.0