{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/10081","labels_url":"https://api.github.com/repos/laravel/framework/issues/10081/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/10081/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/10081/events","html_url":"https://github.com/laravel/framework/issues/10081","id":103866341,"number":10081,"title":"[5.0] [Bug?] Push queues serialization problem (unserialize(): Error at offset ...)","user":{"login":"rulrok","id":3097987,"avatar_url":"https://avatars.githubusercontent.com/u/3097987?v=3","gravatar_id":"","url":"https://api.github.com/users/rulrok","html_url":"https://github.com/rulrok","followers_url":"https://api.github.com/users/rulrok/followers","following_url":"https://api.github.com/users/rulrok/following{/other_user}","gists_url":"https://api.github.com/users/rulrok/gists{/gist_id}","starred_url":"https://api.github.com/users/rulrok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rulrok/subscriptions","organizations_url":"https://api.github.com/users/rulrok/orgs","repos_url":"https://api.github.com/users/rulrok/repos","events_url":"https://api.github.com/users/rulrok/events{/privacy}","received_events_url":"https://api.github.com/users/rulrok/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-29T17:43:36Z","updated_at":"2015-08-29T18:01:04Z","closed_at":"2015-08-29T18:01:04Z","body":"I'm deploying my laravel project to Google App Engine (gae) and I'm trying to use their push queue.\r\nFor accomplishing this, [GaeSupportL5](https://github.com/shpasser/GaeSupportL5) package is being used. This should work very similar to __iron.io__, but the problem that I'm facing suggests for me that this is something more related to laravel itself rather than this plugin, and this will be more clear at the end of my explanation. Even then, I opened an [issue](https://github.com/shpasser/GaeSupportL5/issues/33) there as well for something else that I've noticed wrong.\r\n\r\nWhat I do is dispatching a job to gae push queue to release the user request right way.\r\n\r\nThis is my controller.\r\n\r\n```php\r\n        $this->dispatch(\r\n            new DispatchPendentSceneToVM(\r\n                $scene_id\r\n                , Request::get('type')\r\n            )\r\n        );\r\n```\r\n\r\nAnd here is the job class.\r\n\r\n```php\r\n<?php namespace App\\Commands;\r\n\r\nuse Illuminate\\Queue\\InteractsWithQueue;\r\nuse Illuminate\\Queue\\SerializesModels;\r\nuse Illuminate\\Support\\Facades\\Queue;\r\nuse Illuminate\\Support\\Facades\\Log;\r\n\r\nuse Illuminate\\Contracts\\Bus\\SelfHandling;\r\nuse Illuminate\\Contracts\\Queue\\ShouldBeQueued;\r\n\r\nclass DispatchPendentSceneToVM extends Command implements SelfHandling, ShouldBeQueued {\r\n\r\n    use InteractsWithQueue, SerializesModels;\r\n\r\n    public $i_scene_id;\r\n    public $s_type;\r\n\r\n    public function __construct($i_scene_id, $s_type) {\r\n        $this->i_scene_id = $i_scene_id;\r\n        $this->s_type = $s_type;\r\n    }\r\n\r\n    public function handle() {\r\n\r\n        /*\r\n         * Queue the job to crop the image and update the scene table\r\n         */\r\n        try {\r\n            Log::info('Going to connect to beanstalkd');\r\n\r\n            Queue::connection('images_connection')->push(\r\n                new ProcessSceneImage(\r\n                    $this->i_scene_id\r\n                    , $this->s_type\r\n                )\r\n            );\r\n        } catch (\\Exception $e) {\r\n            Log::error('Could not connect to beanstalkd');\r\n            $this->release(60); //1 minute waiting\r\n        }\r\n    }\r\n\r\n\r\n}\r\n```\r\n\r\nInside this dispatched job to gae push queue, I'm simply dispatching another job to a different queue.  I'm doing this just because sometimes the connection to _images_connection_ would take longer and I don't want the user request to be hold by that, or rather it would fail and the user experience would be poor. (I want the job to keep trying to connect to this external queue. This external one is a beanstalkd queue).\r\n\r\nFor receiving the task, I'm just marshalling it on the route __/tasks__.\r\n\r\n```php\r\n$route->post('tasks', array('as' => 'tasks',\r\n    function()\r\n    {\r\n        return Queue::marshal();\r\n    }));\r\n```\r\n\r\nBefore I was receiving weird unserialize() php error with a string similar to this\r\n```json\r\n{\r\n  \"job\": \"Illuminate\\\\Queue\\\\CallQueuedHandler@call\",\r\n  \"data\": {\r\n    \"command\": \"O:37:\\\"App\\\\Commands\\\\DispatchPendentSceneToVM\\\":3:{s:49:\\\"\"\r\n  },\r\n  \"attempts\": 1,\r\n  \"queue\": \"default\"\r\n}\r\n```\r\n\r\nI noticed that this string was looking strange and missing my class properties. Then I realized that I had my properties as private. Accordingly to PHP.net [documentation for serialize](http://br2.php.net/manual/en/function.serialize.php):\r\n\r\n```\r\nNote:\r\nObject's private members have the class name prepended to the member name; protected members have a '*' prepended to the member name. These prepended values have null bytes on either side.\r\n```\r\n\r\nThen I changed both __$s_type__ and __$i_scene_id__ variable to public. That seemed to have worked. But the next problem would look like this:\r\n\r\n```json\r\n{\r\n  \"job\": \"Illuminate\\\\Queue\\\\CallQueuedHandler@call\",\r\n  \"data\": {\r\n    \"command\": \"O:37:\\\"App\\\\Commands\\\\DispatchPendentSceneToVM\\\":3:{s:10:\\\"i_scene_id\\\";i:18;s:6:\\\"s_type\\\";s:4:\\\"cube\\\";s:6:\\\"\"\r\n  },\r\n  \"attempts\": 1,\r\n  \"queue\": \"default\"\r\n}\r\n```\r\n\r\nSo, I was noticing that my serialized object string was indicating that the class _DispatchPendentSceneToVM_ has 3 properties, but in fact I was using only two, namely _$s_type_ and _$i_scene_id_.\r\n\r\nIt turned out that this third mysterious variable was coming from the __InteractsWithQueue__ trait. Namely, the _protected_ variable __$job__.\r\n\r\n```php\r\n<?php namespace Illuminate\\Queue;\r\n\r\nuse Illuminate\\Contracts\\Queue\\Job as JobContract;\r\n\r\ntrait InteractsWithQueue {\r\n\r\n\t/**\r\n\t * The underlying queue job instance.\r\n\t *\r\n\t * @var \\Illuminate\\Contracts\\Queue\\Job\r\n\t */\r\n\tprotected $job;\r\n\r\n      (rest of code ...)\r\n}\r\n```  \r\n\r\nI changed this variable to public just to test, and surprisingly (or maybe not), everything worked fine!\r\nNow I didn't get an unserialize exception.\r\n\r\nBelow is the stack track from when I get the error (when the __$job__ variable is set as protected).\r\n\r\n```php\r\nin CallQueuedHandler.php line 36\r\nat HandleExceptions->handleError('8', 'unserialize(): Error at offset 96 of 99 bytes', '/base/data/home/apps/s~panopla-1010/alpha-0.386779994424105697/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php', '36', array('job' => object(GaeJob), 'data' => array('command' => 'O:37:\"App\\Commands\\DispatchPendentSceneToVM\":3:{s:10:\"i_scene_id\";i:3;s:6:\"s_type\";s:4:\"flat\";s:6:\"')))\r\nat unserialize('O:37:\"App\\Commands\\DispatchPendentSceneToVM\":3:{s:10:\"i_scene_id\";i:3;s:6:\"s_type\";s:4:\"flat\";s:6:\"') in CallQueuedHandler.php line 36\r\nat CallQueuedHandler->call(object(GaeJob), array('command' => 'O:37:\"App\\Commands\\DispatchPendentSceneToVM\":3:{s:10:\"i_scene_id\";i:3;s:6:\"s_type\";s:4:\"flat\";s:6:\"')) in Job.php line 126\r\nat Job->resolveAndFire(array('job' => 'Illuminate\\Queue\\CallQueuedHandler@call', 'data' => array('command' => 'O:37:\"App\\Commands\\DispatchPendentSceneToVM\":3:{s:10:\"i_scene_id\";i:3;s:6:\"s_type\";s:4:\"flat\";s:6:\"'), 'attempts' => '1', 'queue' => 'default')) in GaeJob.php line 56\r\nat GaeJob->fire() in GaeQueue.php line 163\r\nat GaeQueue->marshal()\r\nat call_user_func_array(array(object(GaeQueue), 'marshal'), array()) in QueueManager.php line 223\r\nat QueueManager->__call('marshal', array()) in Facade.php line 207\r\nat QueueManager->marshal() in Facade.php line 207\r\nat Facade::__callStatic('marshal', array()) in routes_web.php line 16\r\nat Queue::marshal() in routes_web.php line 16\r\nat RouteServiceProvider->{closure}()\r\nat call_user_func_array(object(Closure), array()) in Route.php line 157\r\nat Route->runCallable(object(Request)) in Route.php line 129\r\nat Route->run(object(Request)) in Router.php line 701\r\nat Router->Illuminate\\Routing\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 141\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 101\r\nat Pipeline->then(object(Closure)) in Router.php line 703\r\nat Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 670\r\nat Router->dispatchToRoute(object(Request)) in Router.php line 628\r\nat Router->dispatch(object(Request)) in Kernel.php line 214\r\nat Kernel->Illuminate\\Foundation\\Http\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 141\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in VerifyCsrfToken.php line 23\r\nat VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in ShareErrorsFromSession.php line 55\r\nat ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in StartSession.php line 61\r\nat StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36\r\nat AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in EncryptCookies.php line 40\r\nat EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42\r\nat CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 101\r\nat Pipeline->then(object(Closure)) in Kernel.php line 115\r\nat Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84\r\nat Kernel->handle(object(Request)) in index.php line 53\r\n```\r\n\r\nChanging the variable from __protected__ to __public__, and making the request again, the server only returns with a 200 OK message.\r\n\r\nI'm doing something wrong, or should this variable really be public for the sake of serialization?\r\n\r\nThank you"}}