Posted by smiletrl on January 30, 2013 at 8:31am
7 followers
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | rest.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
| Issue tags: | WSCCI |
Issue Summary
Problem/Motivation
Enable rest module, go to 'admin/config/services/rest', and save content exposed as web service.
Go to 'entity/node/1', I get error:Fatal error: Unsupported operand types in D:\Apache\drupal8\core\modules\jsonld\lib\Drupal\jsonld\JsonldEntityNormalizer.php on line 37
By the way, I'm using a win7 system.
Comments
#1
I'm on a Mac running PHP 5.3.15 and get the same thing, so it isn't a platform/version problem.
Line 33
$attributes = $entity_wrapper->getProperties();is returning nothing, so the$attributes = array( ... ) + $attributesis puking. The attached patch fixes the problem by returning an empty array from$entity_wrapper->getProperties()no matter what.<?php
diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php
index a2e49e3..458a96a 100644
--- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php
+++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php
@@ -124,7 +124,7 @@ public function getProperties() {
}
// Only return properties which are not in the $skip array.
- return array_diff_key($properties, array_fill_keys($skip, ''));
+ return array_diff_key($properties, array_fill_keys($skip, '')) ? array_diff_key($properties, array_fill_keys($skip, '')) : array();
}
}
?>
My apologies for being fairly new to contributing patches and unsure if this is the appropriate way to address the issue. Regardless, it should help you guys track it down quickly.
#2
#3
Nodes are not yet converted to EntityNG, so this postponed on #1818556: Convert nodes to the new Entity Field API.
#4
After apply the patch, I still get the error.
Anyway, I get wierd result:
{"@id":"http:\/\/localhost\/drupal8\/node\/1","@type":"http:\/\/localhost\/drupal8\/site-schema\/content-deployment\/node\/article"}From my point of view, patch in #1 suppresses the problem, not actuall solve the problem^^
I still get errors on other pages
<?phpWarning: Invalid argument supplied for foreach() in Drupal\jsonld\JsonldEntityWrapper->getProperties() (line 117 of core\modules\jsonld\lib\Drupal\jsonld\JsonldEntityWrapper.php).
Notice: Undefined variable: properties in Drupal\jsonld\JsonldEntityWrapper->getProperties() (line 127 of core\modules\jsonld\lib\Drupal\jsonld\JsonldEntityWrapper.php).
Warning: array_diff_key() [function.array-diff-key]: Argument #1 is not an array in Drupal\jsonld\JsonldEntityWrapper->getProperties() (line 127 of core\modules\jsonld\lib\Drupal\jsonld\JsonldEntityWrapper.php).
?>
#5
Yes, you cannot test REST module with nodes right now.