1

Having a weird issue. I have a portal I have developed which up until today has been working good in both the prod and dev environments. Today after running a composer update everything works great on dev environment but when I pushed it to production one of my pages stopped working. The page allows me to pull up a user account and modify certain fields(pretty straight forward).

As an example/test I have created a test function in the controller to spit out a specific users information:

public function getTest(){
    $user = Sentry::findUserByLogin('XXXXX');
    echo $user;
}

When I run this function on the dev side it shows all the information its suppose to. When on the production side I get this error:

production.ERROR: 500 - Method Cartalyst\Sentry\Users\Eloquent\User::__toString() must not throw an exception @ /employees/admin/test
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Method Cartalyst\Sentry\Users\Eloquent\User::__toString() must not throw an exception' in E:\sites\yaya.com\portal\app\src\employees\controllers\admin.php:0
Stack trace:
[internal function]: Illuminate\Exception\Handler->handleShutdown()
{main} [] []

I have not modified anything inside of Sentry or Eloquent.

Any ideas on what would cause this error? On the production side if I do a var_dump(user) it wont throw the error and I can see everything inside the protected fields. Or if I do echo $user->username it also works just fine. Problem is I need to return the user information as well as the groups the user is in to my JS to display it on my screen depending on the drop down selected for the user.

kajetons
  • 4,481
  • 4
  • 26
  • 37
Silent
  • 438
  • 2
  • 6
  • 19
  • Did you update the `Laravel` version ? Is that synced (same version) in both (dev and prod) places ? Are there same `PHP version` installed in both places ? – The Alpha Jun 13 '14 at 21:30
  • Same PHP version on both, I have deleted the portal completely off the production server and copied everything from the dev environment over. As far as Laravel version goes I have it set to laravel/framework:4.2.* so there may have been a minor revision but in either case its still working on dev and not prod even though ive copied every file over. – Silent Jun 13 '14 at 21:36
  • It seems that `echo $user;` is the reason for that error. Probably the `__toString` method is some how corrupted, it's being called automatically when you try to `echo` an `object`. – The Alpha Jun 13 '14 at 21:46
  • Any ideas on what I could try? I have tried re-uploading the code 4 million times :) – Silent Jun 13 '14 at 22:23
  • Maybe rolling back to previous version is the easiest solution for now. – The Alpha Jun 13 '14 at 22:24
  • Rolling back didnt help, that was the first thing I tried doing. I am going to clear out the vendors folder and try to rebuild it to see if something happened there. I found another portion of the script that wasnt working as well so maybe itll help me debug it. – Silent Jun 16 '14 at 12:52
  • Yeah still nothing! I have checked the PHP config to make sure they match and they do. I tried putting the code on another server(its currently on a windows box put it on a linux box to check to make sure it wasnt something goofy on windows) and it didn't work, but still working on my local machine without a single problem. – Silent Jun 16 '14 at 16:29

2 Answers2

1

Finally figured it out! Not sure what happened but I started comparing rows of data in the database and found a few discrepancies. Pulled up the design view and sure enough a couple fields were different on production then my dev enviroment. Instead of "datetime" they were set to "smalldatetime" not sure what would have caused that but changed it to "datetime" and it all started working.

Thanks for the help Werewolf!

Silent
  • 438
  • 2
  • 6
  • 19
0

The most general case when this error is produced is mistype, when, f.e. instead of

{{ $user->id }}

Someone types

{{ $user }}

So error clearly says that method toString was called.

Thelambofgoat
  • 609
  • 1
  • 11
  • 24