VirtualBox

Opened 14 years ago

Closed 14 years ago

#5657 closed defect (fixed)

Problems with vboxServiceWrappers.php module

Reported by: Joe Owned by:
Component: webservices Version: VirtualBox 3.1.0
Keywords: vboxServiceWrappers.php Cc:
Guest type: Linux Host type: Linux

Description

A number of issues have been detected with the PHP wrapper module. Many of the instances are related to a single class and by addressing that issue, it should address a large number of them.

The problems I describe below may also exist in other SDK wrappers as the wrappers are generated from presumably the same code-base.

Where possible, I have provided one possible solution approach to the problem but is not the only way the bug can be fixed.

For Possible solutions, the typecasting in many cases to an array by using '(array)' vs 'array ( ... )' will depend on whether the data-element is an array of objects vs an array of references to an object.

Bugs:

---------------------------------------------------------------------

getDVDDrives method of the IHost object incorrectly tries to build the IMediumCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new IMediumCollection ($this->connection, $response->returnval);

Possible Solutions:

1) return new IMediumCollection ($this->connection, array ($response->returnval)); 2) return new IMediumCollection ($this->connection, (array) $response->returnval);

---------------------------------------------------------------------

getFloppyDrives method of the IHost object incorrectly tries to build the IMediumCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new IMediumCollection ($this->connection, $response->returnval);

Should Be:

return new IMediumCollection ($this->connection, array ($response->returnval));

---------------------------------------------------------------------

getFloppyImages method of the IVirtualBox object incorrectly tries to build the IMediumCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new IMediumCollection ($this->connection, $response->returnval);

Should Be:

return new IMediumCollection ($this->connection, array ($response->returnval));

---------------------------------------------------------------------

IMediumCollection in general: It seems when an IMedium collection is used, an array of reference IDs (handles) is returned rather than an array of IMedium objects.

e.g: Array (

[0] '20e6f88ea0bffc6d-0000000000000822'

[1] '20e6f88ea0bffc6d-0000000000000823'

[2] '20e6f88ea0bffc6d-0000000000000824'

[3] '20e6f88ea0bffc6d-0000000000000825'

[4] '20e6f88ea0bffc6d-0000000000000826'

)

The work-around for IMediumAttachment::getMedium below can allow developers to build the IMedium object on-the-fly if this scenario should happen.

IMediumAttachment::getMedium method retuns a string (with the handle for the IMedium object) rather than returning the IMedium object.

Work-Around:

$mediumAttachmentRefList = $machine->getMediumAttachments (); foreach ($mediumAttachmentRefList as $mediumAttachmentRef) {

$mediumRef = $mediumAttachmentRef->getMedium ();

BUG w/ 3.1 APIs ... mediumRef should be an object

however, an internal reference pointer string is returnd

handle for both string and object until it's fixed

if (!is_object ($mediumRef))

$mediumRef = new IMedium ($this->connection, $mediumRef);

NOTE: The work-around above assumes $machine is valid and is of type IMachine

---------------------------------------------------------------------

IMedium::getMachineIds type-casts to string which is not correct.

Current code:

return (string)$response->returnval;

Should Be

return (array)$response->returnval;

---------------------------------------------------------------------

getSharedFolders method of the IVirtualBox object incorrectly tries to build the ISharedFolderCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new ISharedFolderCollection ($this->connection, $response->returnval);

Should Be:

return new ISharedFolderCollection ($this->connection, array ($response->returnval));

or

return new ISharedFolderCollection ($this->connection, (array) $response->returnval);

---------------------------------------------------------------------

getDHCPServers method of the IVirtualBox object incorrectly tries to build the IDHCPServerCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new ISharedFolderCollection ($this->connection, $response->returnval);

Should Be:

return new IDHCPServerCollection ($this->connection, $response->returnval);

or

return new IDHCPServerCollection ($this->connection, (array) $response->returnval);

---------------------------------------------------------------------

getProgressOperations method of the IVirtualBox object incorrectly tries to build the IProgressCollection object ..

  • Should pass an array of items for parameter number 2 ... not a string.

Current code:

return new ISharedFolderCollection ($this->connection, $response->returnval);

Should Be:

return new IProgressCollection ($this->connection, array ($response->returnval));

or

return new IProgressCollection ($this->connection, (array) $response->returnval);

---------------------------------------------------------------------

getObject method on the IPerformanceMetric class attempts to return an 'unknown' object

---------------------------------------------------------------------

getInitiator method on the IProgress class attempts to return a '$unknown' object ... but $unknown is not defined.

Change History (2)

comment:1 by James Lucas, 14 years ago

Fixed in 3.1.8 / 3.2

comment:2 by Frank Mehnert, 14 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use