Opened 3 years ago
Closed 3 years ago
#2375 closed Defect (fixed)
Insufficient error checking in getContainer() (objects.php)
| Reported by: | StanD | Owned by: | ewinslow |
|---|---|---|---|
| Priority: | low | Milestone: | Elgg 1.8.0 |
| Component: | Core | Version: | 1.7 |
| Severity: | trivial | Keywords: | |
| Cc: | brettp | Difficulty: | easy |
Description
Function getContainer() (called from getContainerEntity()) does a simple "return":
function getContainer() {
return $this->get('container_guid');
}
As a result, if the container_guid is not set, the results are unpredictable - and getContainerEntity() causes PHP to crash. This comes up when running getContainerEntity() on a list of entities that includes ElggUser and ElggGroup object... PHP definitely goes kaboom.
It'd be better if getContainer did a rudimentary check and returned false (or null) if the container_guid was not found.
Change History (4)
comment:1 Changed 3 years ago by cash
comment:2 Changed 3 years ago by brettp
- Difficulty set to easy
- Priority changed from normal to low
- Severity changed from minor to trivial
comment:3 Changed 3 years ago by ewinslow
- Owner set to ewinslow
- Status changed from new to assigned
comment:4 Changed 3 years ago by ewinslow
- Resolution set to fixed
- Status changed from assigned to closed
Fixed in [svn:7219]
Note: See
TracTickets for help on using
tickets.

The issue is that the Container methods only exist for the ElggObject class. Ticket #2134 is about adding the methods to the ElggEntity class which would fix this problem. Until then, the plugin causing this problem needs to do a check for class type before calling the container methods.