You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Microsoft Graph PHP SDK to retrieve items from a OneDrive directory, the DriveItemCollectionResponse and its nested DriveItem objects expose properties in the print_r() output. However, these properties cannot be accessed programmatically, making it impossible to extract data like name, createdBy, and other fields.
Steps to Reproduce
Query OneDrive items using the SDK:
$response = $graphClient->me()->drive()->items()->get();
$items = $response->getValue();
// Attempt to access propertiesforeach ($itemsas$item) {
$name = $item->name; // Property does not exist or is inaccessible$createdBy = $item->createdBy; // Same issue
}
Inspect the object using print_r($response):
It shows that properties such as name and createdBy are present in the object structure.
Try accessing these properties directly:
$name = $item->getBackingStore()->get('name'); // Produces inconsistent results or null
Attempt to convert the object to JSON or an array:
functionobjectToArray($object) {
if (is_object($object)) {
$object = get_object_vars($object);
}
if (is_array($object)) {
returnarray_map('objectToArray', $object);
}
return$object;
}
$data = objectToArray($response); // Results in null values
Expected Behavior
At a minimum, properties like name, createdBy, id, etc., should be accessible programmatically from the DriveItem objects within the DriveItemCollectionResponse.
Actual Behavior
DriveItem properties cannot be accessed programmatically even though they appear in the object structure when printed using print_r().
Converting the object to an array or JSON results in null values for most properties.
Workarounds Attempted
Direct Access: Accessing properties like $item->name directly results in an error.
Using Backing Store: The getBackingStore() method does not reliably return property values.
Recursive Conversion: Converting the response to an array using custom functions results in null for properties.
Proposed Solution
Ensure all properties are accessible programmatically from DriveItem objects.
Add a built-in method to convert objects to arrays or JSON for easier integration with AJAX-based frontend applications.
Provide documentation with examples on how to access and use properties programmatically.
Environment
PHP Version: 8.4.2
SDK Version: 2.23
Additional Context
This issue significantly limits the usability of the SDK for modern applications.
Being unable to access properties programmatically or convert the response to JSON prevents integration with frontend frameworks like React.
If there is a specific intended way to access these properties, it should be explicitly documented.
The text was updated successfully, but these errors were encountered:
Issue Summary
When using the Microsoft Graph PHP SDK to retrieve items from a OneDrive directory, the
DriveItemCollectionResponse
and its nestedDriveItem
objects expose properties in theprint_r()
output. However, these properties cannot be accessed programmatically, making it impossible to extract data likename
,createdBy
, and other fields.Steps to Reproduce
Query OneDrive items using the SDK:
Inspect the object using
print_r($response)
:name
andcreatedBy
are present in the object structure.Try accessing these properties directly:
Attempt to convert the object to JSON or an array:
Expected Behavior
At a minimum, properties like
name
,createdBy
,id
, etc., should be accessible programmatically from theDriveItem
objects within theDriveItemCollectionResponse
.Actual Behavior
DriveItem
properties cannot be accessed programmatically even though they appear in the object structure when printed usingprint_r()
.null
values for most properties.Workarounds Attempted
$item->name
directly results in an error.getBackingStore()
method does not reliably return property values.null
for properties.Proposed Solution
DriveItem
objects.Environment
Additional Context
The text was updated successfully, but these errors were encountered: