Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to get property of non-object #136

Closed
damngoode opened this issue Apr 24, 2014 · 25 comments
Closed

Trying to get property of non-object #136

damngoode opened this issue Apr 24, 2014 · 25 comments

Comments

@damngoode
Copy link

After creating a software license and checking it out I am no longer able to view assets/software checked out be that user. Checking in the software does not correct the problem. Below is the error log that it returned:

Server/Request Data
HTTP_HOST 192.168.202.5
HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.5
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_REFERER http://192.168.202.5/public/index.php/admin/users
HTTP_COOKIE laravel_session=icomggq1occghua1ehaaifono0
HTTP_CONNECTION keep-alive
PATH /usr/local/bin:/usr/bin:/bin
SERVER_SIGNATURE

Apache/2.2.22 (Ubuntu) Server at 192.168.202.5 Port 80
SERVER_SOFTWARE Apache/2.2.22 (Ubuntu)
SERVER_NAME 192.168.202.5
SERVER_ADDR 192.168.202.5
SERVER_PORT 80
REMOTE_ADDR 192.168.101.17
DOCUMENT_ROOT /var/www
SERVER_ADMIN webmaster@localhost
SCRIPT_FILENAME /var/www/public/index.php
REMOTE_PORT 59536
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING
REQUEST_URI /public/index.php/admin/users/1/view
SCRIPT_NAME /public/index.php
PATH_INFO /admin/users/1/view
PATH_TRANSLATED /var/www/admin/users/1/view
PHP_SELF /public/index.php/admin/users/1/view
REQUEST_TIME 1398370638
GET Data empty
POST Data empty
Files empty
Cookies
laravel_session icomggq1occghua1ehaaifono0
Session
_sf2_attributes Array ( [_token] => xhQ3pzDeUsUO6nzqqqDtoNRYmMtyQ8KvLgnzAEeW [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) [cartalyst_sentry] => Array ( [0] => 1 [1] => $2y$10$u49S9HrVMERGLONV82JNAOWRKimI89kITn38HprJ3w0gHFlq1DYnK ) )
_sf2_flashes Array ( )
_sf2_meta Array ( [u] => 1398370638 [c] => 1398364213 [l] => 7200 )
Environment Variables empty
Registered Handlers

@snipe
Copy link
Owner

snipe commented Apr 29, 2014

Hi there - sorry for the delay, I was out at a conference. Which branch did you grab, dev or master?

When you see "Trying to get property of non-object", does it give you a line number or file number in the error?

@KurzweilTV
Copy link

Maybe I can add to this. I'm getting the same error. I get an error anytime I click a user that has assets assigned.

here is my log-apache2handler if that helps

[2014-05-09 18:18:19] local.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in /var/www/html/snipe/app/storage/views/489d70106fe6d379bc30d8c5385026ca:144
Stack trace:
#0 /var/www/html/snipe/app/storage/views/489d70106fe6d379bc30d8c5385026ca(144): Illuminate\Exception\Handler->handleError(8, 'Trying to get p...', '/var/www/html/s...', 144, Array)
#1 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(37): include('/var/www/html/s...')
#2 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\Engines\PhpEngine->evaluatePath('/var/www/html/s...', Array)
#3 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEngine->get('/var/www/html/s...', Array)
#4 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(102): Illuminate\View\View->getContents()
#5 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(76): Illuminate\View\View->renderContents()
#6 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Http/Response.php(70): Illuminate\View\View->render()
#7 /var/www/html/snipe/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(202): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#8 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1427): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#9 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1003): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View))
#10 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(968): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#11 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(738): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#12 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#13 /var/www/html/snipe/vendor/barryvdh/laravel-debugbar/src/Barryvdh/Debugbar/Middleware.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#14 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php(38): Barryvdh\Debugbar\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#15 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#16 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#17 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#18 /var/www/html/snipe/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#19 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#20 /var/www/html/snipe/public/index.php(49): Illuminate\Foundation\Application->run()
#21 {main}

Next exception 'ErrorException' with message 'Trying to get property of non-object (View: /var/www/html/snipe/app/views/backend/users/view.blade.php)' in /var/www/html/snipe/app/storage/views/489d70106fe6d379bc30d8c5385026ca:144
Stack trace:
#0 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(41): Illuminate\View\Engines\CompilerEngine->handleViewException(Object(ErrorException))
#1 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\Engines\PhpEngine->evaluatePath('/var/www/html/s...', Array)
#2 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEngine->get('/var/www/html/s...', Array)
#3 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(102): Illuminate\View\View->getContents()
#4 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/View/View.php(76): Illuminate\View\View->renderContents()
#5 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Http/Response.php(70): Illuminate\View\View->render()
#6 /var/www/html/snipe/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(202): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#7 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1427): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#8 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1003): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View))
#9 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Routing/Router.php(968): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#10 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(738): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#11 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#12 /var/www/html/snipe/vendor/barryvdh/laravel-debugbar/src/Barryvdh/Debugbar/Middleware.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#13 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php(38): Barryvdh\Debugbar\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#14 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#15 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#16 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#17 /var/www/html/snipe/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#18 /var/www/html/snipe/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#19 /var/www/html/snipe/public/index.php(49): Illuminate\Foundation\Application->run()
#20 {main} [] []

@snipe
Copy link
Owner

snipe commented May 9, 2014

Can you tell me what error you see on screen?

@KurzweilTV
Copy link

server error 500

@snipe
Copy link
Owner

snipe commented May 9, 2014

Are you running this as production or local? If you run it as local, you'll see a more useful error message on screen.

@KurzweilTV
Copy link

I think production. I'm not the one that did the original setup. If it can be changed to local I'll see about doing that. This is from the 0.32 release

@snipe
Copy link
Owner

snipe commented May 9, 2014

Okay - if you can run it as test or local, that would definitely help me to help you. It should show you a line number with the offending bit, and I can help you debug from there.

@snipe
Copy link
Owner

snipe commented May 9, 2014

(When it's in production mode, it gives more user-facing, generic error messages - dev/test mode gives a full stack trace and more detailed debugging.)

@KurzweilTV
Copy link

I hate to ask, but is there an easy way to switch between the two?

@snipe
Copy link
Owner

snipe commented May 9, 2014

No worries :) Easiest way is to adjust the environment settings here:
https://github.com/snipe/snipe-it#2-setup-environment-database-and-mail-settings

@KurzweilTV
Copy link

Hmm followed that but I still get generic errors. I'll have to try later. Busy day. :(

@snipe
Copy link
Owner

snipe commented May 9, 2014

It will default to production if the hostname doesn't match, so that may be part of the problem. When you type hostname, does it match what you have as local, and NOT what you have as anything else in that block?

@KurzweilTV
Copy link

Yeah it matches exactly, and only the section that says local.

On Fri, May 9, 2014 at 12:41 PM, snipe notifications@github.com wrote:

It will default to production if the hostname doesn't match, so that may
be part of the problem. When you type hostname, does it match what you
have as local, and NOT what you have as anything else in that block?


Reply to this email directly or view it on GitHubhttps://github.com//issues/136#issuecomment-42705578
.

@snipe
Copy link
Owner

snipe commented May 9, 2014

Hmm, okay. A few more questions for both of you if you get a chance:

  • does this happen with any user, or just a selection of them?
  • does this happen with software and hardware, or just software?
  • does this happen with any assets, or just assets you create and assign?

If you remove the following:

@if ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at==''))
    <a href="{{ route('view/hardware', $log->asset_id) }}">{{ $log->assetlog->asset_tag }}</a>
@elseif ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at!=''))
    <del>{{ $log->assetlog->name }}</del> (deleted)
@else
missing asset ({{ $log->assetlog->name }}) ({{ $log->assetlog->deleted_at }})
@endif

from app/views/users/backend/view.blade.php and reload, does it help?

I'm having a hard time reproducing it on my end, so I'm trying to isolate the use cases. :(

@KurzweilTV
Copy link

Sorry for the lack of info. I find out what I can.

On Friday, May 9, 2014, snipe notifications@github.com wrote:

Hmm, okay. A few more questions for both of you if you get a chance:

  • does this happen with any user, or just a selection of them?
  • does this happen with software and hardware, or just software?
  • does this happen with any assets, or just assets you create and
    assign?

If you remove the following:

@if ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at==''))
{{ $log->assetlog->asset_tag }}
@elseif ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at!=''))
{{ $log->assetlog->name }} (deleted)
@else
missing asset ({{ $log->assetlog->name }}) ({{ $log->assetlog->deleted_at }})
@endif

from app/views/users/backend/view.blade.php and reload, does it help?

I'm having a hard time reproducing it on my end, so I'm trying to isolate
the use cases. :(


Reply to this email directly or view it on GitHubhttps://github.com//issues/136#issuecomment-42707759

@snipe
Copy link
Owner

snipe commented May 9, 2014

No problem - sorry you're having trouble. PS - I edited your comments to remove your phone number, for probably obvious reasons. I think it was included because you replied via email, and it's in your sig.

@KurzweilTV
Copy link

Thanks for the edit!

Also, it was only happening to users with software assets assigned, users with hardware were okay.
Removing that block made it work perfectly. Thank you, and I hope that helps!

@snipe
Copy link
Owner

snipe commented May 11, 2014

That does help, thank you! I'll get a patch out for you shortly. I appreciate you taking the time to help troubleshoot. Sucks when you can't reproduce an error locally.

@KurzweilTV
Copy link

Thank YOU! This project is exactly what I needed.

@snipe
Copy link
Owner

snipe commented May 12, 2014

Can you try adding this bit of code after line 139 on app/views/users/backend/view.blade.php? (It's basically the same line you took out before with the last else changed to an elseif.

@if ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at==''))
    <a href="{{ route('view/hardware', $log->asset_id) }}">{{ $log->assetlog->asset_tag }}</a>
@elseif ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at!=''))
    <del>{{ $log->assetlog->name }}</del> (deleted)
@elseif (!isset($log->assetlog->name))
missing asset ({{ $log->assetlog->name }}) ({{ $log->assetlog->deleted_at }})
@endif

If this works, that's really weird. That statement should only evaluate to true if the asset itself or the entry in the log table is missing, which should never happen, since assets are marked as deleted, but never truly deleted.

Edit: Updated to correct the code. Use this version, not the one you were emailed with the github response.

@KurzweilTV
Copy link

Tried the new code.

I get the original error when I use it.

@snipe
Copy link
Owner

snipe commented May 12, 2014

Dammit. :( Thanks. Stay tuned.

@snipe
Copy link
Owner

snipe commented May 12, 2014

Try this?

@if ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at==''))
    <a href="{{ route('view/hardware', $log->asset_id) }}">{{ $log->assetlog->asset_tag }}</a>
@elseif ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at!=''))
    <del>{{ $log->assetlog->name }}</del> (deleted)
@endif

So sorry for all this back and forth. I still can't repro, so I'm still flying blind. :(

@KurzweilTV
Copy link

No prob. Happy to help

This one works perfectly.

@snipe
Copy link
Owner

snipe commented May 12, 2014

Excellent! I'll submit this patch into dev and master, so the next time you grab code, the fix will be in there. Really appreciate all of your help!

@snipe snipe closed this as completed in dfa5d1c May 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants