0

I recently bumped into a problem with CakePHP 3.

We are working with a Nginx Server and a Postgres Database. When I try to access a model's property that is NULL, I get an 502 Bad Gateway error, even something simple such as debug($object['editor_id']);die;.

The column editor_id is type integer, has no modifiers (so no 'not null' and no 'default'), storage is plain.

If this field is not empty, I don't have any problems. Right now that I identified the object generating the 502 error, I have no idea where to search for a solution. What can be potentially wrong with my setup? Also strange is, that the system is working everywhere else but this special case... I'd be glad if anyone can help me with this or has a idea how to further debug.

Thank you!

EDIT: Here is just an examplary code snippet:

$this->loadModel('Elements');

$object = $this->Elements->find()->where(['id' => 594])->first();

debug($object['editor_id']);

And 502 Bad Gateway...

  • Maybe some addition: If I write `debug($object)` without the field, I get a beautiful description of my object, even the field *editor_id* is *null*. This whole thing does not work for other fields that are null, too. – F. Eichhorst Mar 31 '17 at 14:16
  • it seems that debug() function does not handle null arguments... – St3an Mar 31 '17 at 14:21
  • Unfortunately it also doesn't work with is_null for example. Also, how can a PHP error lead to a Nginx 502? – F. Eichhorst Mar 31 '17 at 14:28
  • Check your server (error) logs. May be something like **http://stackoverflow.com/questions/17708152/nginx-overwrites-general-symfony-errors-with-502-bad-gateway**. ps `debug()` should be able to handle `null` just fine. – ndm Mar 31 '17 at 16:08
  • Thanks for your replies. I found out that this also not works on my local machine with Apache. I get the following error there: **FastCGI: incomplete headers (0 bytes) received from server** Regardless which field I try to access, if it is NULL, the server crashes with Apache and Nginx. I am running CakePHP 3.3.15, also tried 3.4.* – F. Eichhorst Mar 31 '17 at 16:16
  • You need to look for an error message (in your nginx/apache error log is where to start, then phpfpm, then your own application logs). `When I try to access a model's property that is NULL` - beware of false assumptions, this statement is probably misleading. You aren't accessing something set to null you're [calling magic methods](https://github.com/cakephp/cakephp/blob/master/src/Datasource/EntityTrait.php#L127-L161) - which can and do throw exceptions/fail depending on the code that you haven't shown in the question. To get help you must provide more information. – AD7six Apr 12 '17 at 13:44

0 Answers0