Opened 2 years ago
Closed 2 years ago
#3392 closed Defect (worksforme)
trim() php warning on elgg_get_entities with 'order_by'
| Reported by: | ismayil.khayredinov | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Needs Review |
| Component: | Core | Version: | 1.7 |
| Severity: | minor | Keywords: | |
| Cc: | brett@… | Difficulty: |
Description
I am not sure if it's an error on my end, or there is a problem with sanitise_string function, but my error log was being populated with trim() php warning (http://community.elgg.org/mod/groups/topicposts.php?topic=714881&group_guid=179063) in my Edifice plugin.
Having done some digging around, and thanks to NetBeans and Xdebug, I've managed to locate the source of the error. It's being triggered by the elgg_get_entities_from_metadata and elgg_get_entities_from_relationship.
Here are the examples:
$categories = elgg_get_entities_from_metadata(array(
'metadata_name' => 'level',
'metadata_value' => 1,
'type' => 'object',
'subtype' => 'category',
'limit' => 9999,
'order_by' => array('name' => 'title', 'direction' => ASC, 'as' => text)));
$objects = elgg_get_entities_from_relationship(array(
'relationship' => 'child',
'relationship_guid' => $category_guid,
'inverse_relationship' => true,
'types' => 'object',
'subtypes' => 'category',
'limit' => 9999,
'order_by' => array('name' => 'title', 'direction' => ASC, 'as' => text)));
When 'order_by' is removed, the errors disappear from the log.
Both of the above produce the results that I need, that is sort the array alphabetically according to title. Yet, they produce the trim() error.
Change History (1)
comment:1 Changed 2 years ago by brettp
- Resolution set to worksforme
- Status changed from new to closed

The order_by option only accepts a string. You probably want order_by_metadata, which accepts that style array.