If a model has relations without alias like:
class News extends \PhalconRest\API\BaseModel {
[...]
public function initialize() {
parent::initialize();
$this->belongsTo('user_id', Users::class, 'id');
$this->hasMany('id', NewsComments::class, 'news_id');
}
}
A request to http://192.168.125.64/v1/news?include=
(notice the empty "include")
Raise an error:
Notice: ob_clean(): failed to delete buffer. No buffer to delete in /var/www/vendor/gte451f/phalcon-json-api-package/src/bin/errorHandler.php on line 162
{
"errors": [
{
"title": "Fatal Error Ocurred - NOTICE",
"code": 8,
"detail": "Undefined property: Phalcon\\Mvc\\Model\\Row::$Users",
"meta": {
"file": "\/var\/www\/vendor\/gte451f\/phalcon-json-api-package\/src\/API\/Entity.php",
"line": 497,
"stack": [
{
"file": "\/var\/www\/vendor\/gte451f\/phalcon-json-api-package\/src\/API\/Entity.php",
"line": 497,
"function": "{closure}"
},
{
"file": "\/var\/www\/vendor\/gte451f\/phalcon-json-api-package\/src\/API\/Entity.php",
"line": 442,
"function": "processStandardRelationships",
"class": "PhalconRest\\API\\Entity",
"object": {
"activeRelations": {
"Users": {
}
},
"result": {
"outputMode": "error",
"di": {
}
},
"primaryKeyValue": "1",
"searchHelper": {
"suppliedLimit": null,
"suppliedOffset": null,
"suppliedWith": "",
"suppliedSort": null,
"entityLimit": 500,
"entityOffset": null,
"entityWith": "none",
"entitySort": null,
"entitySearchFields": [
],
"isPartial": false,
"isPager": true,
"isCount": false,
"relationships": null,
"suppliedSearchFields": [
],
"di": {
}
},
"hasManyToManyRegistry": [
],
"di": {
}
},
"type": "->"
},
{
"file": "\/var\/www\/vendor\/gte451f\/phalcon-json-api-package\/src\/API\/Entity.php",
"line": 186,
"function": "processRelationships",
"class": "PhalconRest\\API\\Entity",
"object": {
"activeRelations": {
"Users": {
}
},
"result": {
"outputMode": "error",
"di": {
}
},
"primaryKeyValue": "1",
"searchHelper": {
"suppliedLimit": null,
"suppliedOffset": null,
"suppliedWith": "",
"suppliedSort": null,
"entityLimit": 500,
"entityOffset": null,
"entityWith": "none",
"entitySort": null,
"entitySearchFields": [
],
"isPartial": false,
"isPager": true,
"isCount": false,
"relationships": null,
"suppliedSearchFields": [
],
"di": {
}
},
"hasManyToManyRegistry": [
],
"di": {
}
},
"type": "->"
},
{
"file": "\/var\/www\/vendor\/gte451f\/phalcon-json-api-package\/src\/API\/BaseController.php",
"line": 170,
"function": "find",
"class": "PhalconRest\\API\\Entity",
"object": {
"activeRelations": {
"Users": {
}
},
"result": {
"outputMode": "error",
"di": {
}
},
"primaryKeyValue": "1",
"searchHelper": {
"suppliedLimit": null,
"suppliedOffset": null,
"suppliedWith": "",
"suppliedSort": null,
"entityLimit": 500,
"entityOffset": null,
"entityWith": "none",
"entitySort": null,
"entitySearchFields": [
],
"isPartial": false,
"isPager": true,
"isCount": false,
"relationships": null,
"suppliedSearchFields": [
],
"di": {
}
},
"hasManyToManyRegistry": [
],
"di": {
}
},
"type": "->"
},
{
"function": "get",
"class": "PhalconRest\\API\\BaseController",
"object": {
"singularName": "News",
"pluralName": "News",
"di": {
}
},
"type": "->"
}
],
"context": {
"relation": {
},
"baseRecord": {
"phalconRest\\Models\\News": {
"id": "1",
"date": "2007-10-26 18:31:20",
"czas_postu": "2007-10-26 20:31:20",
"title": "",
"content": "xx",
"username": "x",
"user_id": "1",
"comments_count": "0",
"last_comment": null
},
"phalconRest\\Models\\Users": {
"id": "1",
"username": "x",
"old_password": "",
"password": "",
"email": "xx",
"joined": "2007-10-26 19:46:44",
"daily_mails": "1",
"ip": "10.0.0.5",
"timestamp": "2017-03-29 05:52:02",
"language": "xx",
"latitude": "xx",
"longitude": "xx",
"observation_radius": "7",
"country": "xx",
"hour": "7",
"statpic_id": "4",
"last_mail": "2017-03-29 07:52:02",
"last_login": "2017-03-14 22:04:05",
"secid": "xx",
"retrieve_token": null,
"retrieve_expiration": null
}
},
"parentModels": false,
"alias": null,
"refModelName": "Users"
}
}
}
],
"meta": {
"stopwatch": {
"total_run_time": "10.91 ms",
"laps": {
"Booting App": "0.11 ms",
"Loading Routes": "0.63 ms",
"Processing Request": "7.38 ms",
"Gather Records": "2.79 ms"
}
}
}
}
Notice: ob_clean(): failed to delete buffer. No buffer to delete in /var/www/vendor/gte451f/phalcon-json-api-package/src/bin/errorHandler.php on line 65
Fatal error: Uncaught Phalcon\Http\Response\Exception: Response was already sent in phalcon/http/response.zep:611
Stack trace:
#0 /var/www/vendor/gte451f/phalcon-json-api-package/src/API/Output.php(103): Phalcon\Http\Response->send()
#1 /var/www/vendor/gte451f/phalcon-json-api-package/src/API/Output.php(73): PhalconRest\API\Output->_send(Object(stdClass))
#2 /var/www/vendor/gte451f/phalcon-json-api-package/src/bin/errorHandler.php(95): PhalconRest\API\Output->send(Object(PhalconRest\Result\Adapters\JsonApi\Result))
#3 [internal function]: {closure}()
#4 {main}
thrown in phalcon/http/response.zep on line 611