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

Crashing looking for asset #807

Closed
ghost opened this issue May 20, 2015 · 26 comments
Closed

Crashing looking for asset #807

ghost opened this issue May 20, 2015 · 26 comments
Milestone

Comments

@ghost
Copy link

ghost commented May 20, 2015

I did a mass import of 170 assets into the asset table using a csv within PHPMyAdmin but Snipe IT seems to be crashing on one or more of the assets. How can I tell which one it is referring to? Below is the error log:

[2015-05-20 22:41:32] production.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in C:\xampp\htdocs\snipeit\app\controllers\admin\AssetsController.php:1063
Stack trace:
#0 C:\xampp\htdocs\snipeit\app\controllers\admin\AssetsController.php(1063): Illuminate\Exception\Handler->handleError(8, 'Trying to get p...', 'C:\xampp\htdocs...', 1063, Array)
#1 [internal function]: Controllers\Admin\AssetsController->Controllers\Admin{closure}(Object(Asset))
#2 C:\xampp\htdocs\snipeit\vendor\chumper\datatable\src\Chumper\Datatable\Columns\FunctionColumn.php(15): call_user_func(Object(Closure), Object(Asset))
#3 C:\xampp\htdocs\snipeit\vendor\chumper\datatable\src\Chumper\Datatable\Engines\CollectionEngine.php(264): Chumper\Datatable\Columns\FunctionColumn->run(Object(Asset))
#4 [internal function]: Chumper\Datatable\Engines\CollectionEngine->Chumper\Datatable\Engines{closure}(Object(Asset), 89)
#5 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Support\Collection.php(344): array_map(Object(Closure), Array, Array)
#6 C:\xampp\htdocs\snipeit\vendor\chumper\datatable\src\Chumper\Datatable\Engines\CollectionEngine.php(270): Illuminate\Support\Collection->map(Object(Closure))
#7 C:\xampp\htdocs\snipeit\vendor\chumper\datatable\src\Chumper\Datatable\Engines\CollectionEngine.php(123): Chumper\Datatable\Engines\CollectionEngine->compileArray(Object(Illuminate\Support\Collection))
#8 C:\xampp\htdocs\snipeit\vendor\chumper\datatable\src\Chumper\Datatable\Engines\BaseEngine.php(225): Chumper\Datatable\Engines\CollectionEngine->internalMake(Object(Illuminate\Support\Collection), Array)
#9 C:\xampp\htdocs\snipeit\app\controllers\admin\AssetsController.php(1106): Chumper\Datatable\Engines\BaseEngine->make()
#10 [internal function]: Controllers\Admin\AssetsController->getDatatable('Deployed')
#11 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(231): call_user_func_array(Array, Array)
#12 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('getDatatable', Array)
#13 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Controllers\Admin\AssetsController), Object(Illuminate\Routing\Route), 'getDatatable')
#14 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Controllers\Adm...', 'getDatatable')
#15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}('Deployed')
#16 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Route.php(109): call_user_func_array(Object(Closure), Array)
#17 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#18 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#19 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#20 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#21 C:\xampp\htdocs\snipeit\vendor\barryvdh\laravel-debugbar\src\Middleware\Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#22 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#23 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#24 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#25 C:\xampp\htdocs\snipeit\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#26 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#27 C:\xampp\htdocs\snipeit\public\index.php(49): Illuminate\Foundation\Application->run()
#28 {main} [] []

@snipe
Copy link
Owner

snipe commented May 20, 2015

This is why I don't recommend importing directly into the database. This is a relational database system, and the relationships are required for things to function. When you manually import data, you skip those relationships, and things break.

Can you show me what's on line 1063 of C:\xampp\htdocs\snipeit\app\controllers\admin\AssetsController.php? I'm not sure what version you're using, so I can't tell what piece of code is choking on the data you've given it.

@ghost
Copy link
Author

ghost commented May 20, 2015

return $assets->model->name;

@snipe
Copy link
Owner

snipe commented May 20, 2015

Yeah, so it's looking for the name of the model that's associated with the asset, but I'm guessing you don't have any in your CSV. You can try creating an asset model and then updating the DB's model_id column in the assets table to whatever that ID is.

@ghost
Copy link
Author

ghost commented May 20, 2015

I created the models in the database and assigned them to their respective numbers in my csv. I found the culprit, forgot to enter in the model id on my last row in my CSV. after i deleted that record, everything started working. When you talked about how you dont recommend importing this way, do you think that the database will be stable now after it starts getting manipulated? I just dont have time to manually enter in 170 assets into this database from the GUI.....

@snipe
Copy link
Owner

snipe commented May 20, 2015

After you've created the asset model, the DB command you want to run will be something like:

UPDATE assets SET model_id=1

Assuming the ID of the asset model you've just created is 1.

That will set all of your assets to have that asset model associated to them (which means they'll all have the same asset model, and you'll have to go back in later and update them to whatever asset models they should actually belong to.)

(Edit: striking this through so you don't do it, since it looks like you resolved the problem)

@snipe
Copy link
Owner

snipe commented May 20, 2015

Yeah, it should be stable. As long as the assets table is complete, it should be fine.

@snipe snipe closed this as completed May 20, 2015
@ghost
Copy link
Author

ghost commented May 20, 2015

Having another bizarre issue, when I click a user that is assigned to an asset under the various assets list i get a 503 error and this error is generated

[2015-05-20 23:18:42] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:148
Stack trace:
#0 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1054): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1022): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 C:\xampp\htdocs\snipeit\vendor\barryvdh\laravel-debugbar\src\Middleware\Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#7 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#8 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#9 C:\xampp\htdocs\snipeit\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#10 C:\xampp\htdocs\snipeit\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#11 C:\xampp\htdocs\snipeit\public\index.php(49): Illuminate\Foundation\Application->run()
#12 {main} [] []

what is weird is that if i go to the users section and i click on the same user, there is no issue. The URL it redirects me to is the same in both instances too.....

Sorry to be such a pain :(

@snipe
Copy link
Owner

snipe commented May 20, 2015

Can you show me both URLs? (You can obscure your hostname for privacy if it's not on an internet network)

@ghost
Copy link
Author

ghost commented May 20, 2015

just double checked, they arent the same but they do refer to the same number

Working URL: http://localhost/snipeit/public/admin/users/87/view

Broken URL: http://localhost/snipeit/admin/users/87/view

@snipe
Copy link
Owner

snipe commented May 20, 2015

The URLs are not the same. Notice the public bit in one of them? What's the URL to your Snipe-IT install?

@ghost
Copy link
Author

ghost commented May 20, 2015

@snipe
Copy link
Owner

snipe commented May 20, 2015

Looks like maybe you forgot to set your DocumentRoot to public, and are running it at http://localhost/snipeit/public? It should be running at http://localhost/snipeit/, no public directory.

@snipe
Copy link
Owner

snipe commented May 20, 2015

Ah, wait, are you running this in a subdirectory?

@snipe
Copy link
Owner

snipe commented May 20, 2015

I mean, you're obviously running it in a sub-directory. What I'm really asking is whether you intend to be or not. Is http://localhost used for something else, and you want to run this as a sub-directory? Or did that just sort of happen by mistake?

@ghost
Copy link
Author

ghost commented May 20, 2015

This is the directory to the snipeit root C:\xampp\htdocs\snipeit

@snipe
Copy link
Owner

snipe commented May 20, 2015

Can you answer my question above? Trying to determine what your intent was so I can help you get the document root stuff sorted out.

@ghost
Copy link
Author

ghost commented May 20, 2015

It kind of happened by mistake? I have little experience with Apache....

@snipe
Copy link
Owner

snipe commented May 20, 2015

Okay, so is your intent to run it at http://localhost? Meaning there's nothing else on this server?

@ghost
Copy link
Author

ghost commented May 20, 2015

I also access PHPMyAdmin by going to http://localhost/phpmyadmin/ but that's it....

@snipe
Copy link
Owner

snipe commented May 20, 2015

Okay, so you want to set your DocumentRoot in apache to C:\xampp\htdocs\snipeit\public (and restart apache)

@snipe
Copy link
Owner

snipe commented May 20, 2015

What's happening is that C:\xampp\htdocs is the default directory where XAMPP thinks you want your websites to live. localhost = C:\xampp\htdocs.

When you change the DocumentRoot to another location, it tells Apache to look in that different directory for your web files.

I don't remember if XAMPP lets you create multiple hosts easily, but if it does, you may want to create a new entry for snipe-it, so it doesn't make you lose access to your phpMyAdmin.

This tutorial should help: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/

@ivokabadshow
Copy link

Just tried to install the latest snipe-it (e455b2a) on a linux server, but without setting DocumentRoot. Snipe-it needs to run in subdirectory like www.example.com/snipe-it, since DocumentRoot is required for a different application on the same server. To achieve that (well 99% success) just do the following:

  • add the path to the url in the file app/config/production/app.php e.g. 'url' => 'http://www.example.com/snipe-it',
  • modify public/.htaccess in your snipe-it directory as follows
    • after the line RewriteEngine On add the option RewriteBase /snipe-it/. This prevents the rewrite engine to cut out your chosen path.
  • your apache configuration should look like this. Just replace your-path-path with the server path.
Alias /snipe-it "/your-base-path/snipe-it/public"

<Directory /your-base-path/snipe-it/public>
  PassengerEnabled Off
  Allow From All
  AllowOverride All
  Options +Indexes
</Directory>

The missing 1%
However, the problem with the broken URLs still persist, when trying to click on a user at the assets page. The directory snipe-it is cut out. It seems there is a wrong path in app/controllers/admin/AssetsController.php. In the latest commit (e455b2a) on line 1082 simply replace the returnlink from

return link_to('../admin/users/'.$assets->assigned_to.'/view',$assets->assigneduser->fullName());

to

return link_to('admin/users/'.$assets->assigned_to.'/view', $assets->assigneduser->fullName());

essentially removing the leading ../.

This may be a bug, since leading ../ do not matter, if your installation is done in the DocumentRoot. They are ignored. This is different, if you do not have a DocumentRoot for your snipe-it installation.

Can somebody please check if the ../ is necessary in the standard installation for this particular file?

snipe added a commit that referenced this issue Jul 25, 2015
@snipe
Copy link
Owner

snipe commented Jul 25, 2015

This is fixed on 2.0

@snipe
Copy link
Owner

snipe commented Jul 25, 2015

@ivokabadshow If you have access to the apache config, why not run it in a subdomain instead? That way you can set up the document root appropriately, etc.

@ivokabadshow
Copy link

Thanks for the fix. I do have access to the apache config, but not to additional subdomains due to company regulations.

If you find the time you should add the setup to the documentation. It seems many people try to use it without a separate subdomain.

@snipe snipe added this to the v.2.0 milestone Jul 27, 2015
@snipe
Copy link
Owner

snipe commented Jul 29, 2015

Added subdirectories to the docs: http://docs.snipeitapp.com/installation/subdirectory.html

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

2 participants