[vbox-dev] Problems w/ the vboxServiceWrappers.php module

Joseph Smith joseph1962smith at yahoo.com
Fri Dec 4 15:52:59 GMT 2009


Hi,
I've been working extensively on a PHP web interface using the virtual box webservice APIs.  I had already completed a working version of a base class that handled interaction with the APIs using raw Soap calls ... but then came the generated vboxServiceWrappers.php module.  I've been modifying my code to use the wrappers ... but have found some problems.
I have opened Ticket #5657 with an explanation of the issues I have found.
In talking w/ the dev team on IRC, it was suggested I drop a note to this list and include mjlucas on 'cc'.
For your convenience, here is the contents of the ticket I opened:
Ticket #5657 (new defect)Opened 1 day agoProblems with vboxServiceWrappers.php moduleReported by:joseph1962smithAssigned to:Priority:majorComponent:webservicesVersion:VirtualBox 3.1.0Keywords:vboxServiceWrappers.phpCc:Guest type:LinuxHost type:LinuxDescriptionA 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: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 Bereturn (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);
// ---------------------------------------------------------------------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, (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);

// ---------------------------------------------------------------------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.



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20091204/71808798/attachment.html>


More information about the vbox-dev mailing list