snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

All assets disappeared (no changes were made)

Open BrandonWandon opened this issue 7 years ago • 17 comments

Expected Behavior (or desired behavior if a feature request)

When clicking on All Assets, we should be able to see the assets


Actual Behavior

When clicking All Assets, no assets appear. We are still able to manually search them by asset tag and pull them up, but nothing will show in All assets


Please confirm you have done the following before posting your bug report:


Provide answers to these questions:

  • Is this a fresh install or an upgrade? Neither

  • Version of Snipe-IT you're running 4.6.15

  • Version of PHP you're running 7.2.17

  • Version of MySQL/MariaDB you're running 15.1

  • What OS and web server you're running Snipe-IT on Ubuntu 18.04

  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) Pulled from Github

  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error No error

  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error All Assets

  • If a stacktrace is provided in the error, include that too.

  • Any errors that appear in your browser's error console.

  • Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo. Works on demo

  • Include any additional information you can find in storage/logs and your webserver's logs.

  • Include what you've done so far in the installation, and if you got any error messages along the way. No changes were made, other than adding a couple of assets a few days ago

  • Indicate whether or not you've manually edited any data directly in the database No changes

Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.

https://snipe-it.readme.io/docs/getting-help

BrandonWandon avatar Apr 26 '19 12:04 BrandonWandon

If you look in storage/logs at the laravel-[date].log, are you seeing an error similar to...

date_interval_create_from_date_string(): Unknown or bad format ( months) at position 0 (m): The timezone could not be found in the database in D:\webroot\inventory\app\Presenters\AssetPresenter.php:396 

I know that if the asset model that the asset is based upon, doesn't have an EOL set, it will keep it from appearing in the All Assets list. Even setting the EOL to 0 will fix the error, it just really doesn't like it if it's null/empty.

CSAS-Nicholas-Roberts avatar Apr 26 '19 17:04 CSAS-Nicholas-Roberts

So it does look like I have that error in the logs. What should I do to fix that?

BrandonWandon avatar Apr 26 '19 17:04 BrandonWandon

If you go to your site and then go to Settings->Asset Models, make sure every model in the list has an EOL set. Like I said before, even if the model has no EOL, at least set it to 0 so it's not null.

CSAS-Nicholas-Roberts avatar Apr 26 '19 17:04 CSAS-Nicholas-Roberts

Is there a way to do that without having to go through all of them? We have over 300 models in there and that option doesn;t appear in bulk edit

BrandonWandon avatar Apr 26 '19 17:04 BrandonWandon

Unfortunately it looks like the only way to do it for right now.

Honestly this is just a work around. Hopefully in the future the system will assume 0 if nothing is entered.

CSAS-Nicholas-Roberts avatar Apr 26 '19 17:04 CSAS-Nicholas-Roberts

I changed it for a few models and they only seem to show up when specifically searched for. Do you know if this was addressed in the beta? Snipe-IT is unfortunately unusable for us at the moment. And we are unable to roll back because when we did the upgrade to this latest version, we actually swapped machines and moved from Windows to Linux, so we don't have the previous version to go back to

BrandonWandon avatar Apr 26 '19 18:04 BrandonWandon

Alright so after a little bit of tinkering the following change will fix the problem...

The following is the change made in #6922 that fixes the issue

At [snipe site]\app\Presenters check out the file AssetPresenter.php

Change the eol_date function to...

public function eol_date()
{
     if (( $this->purchase_date ) && ( $this->model ) && ($this->model->model->eol)) {
        $date = date_create($this->purchase_date);
        date_add($date, date_interval_create_from_date_string($this->model->model->eol . ' months'));
        return date_format($date, 'Y-m-d');
    }
}

~~This change will make it assume 0 if the value is null so you don't have to update all of them.~~ This change was made by @snipe to fix issue #6922 . Make sure to save a backup of the original function in case it doesn't work (included below just in case)

public function eol_date()
{
    if (( $this->purchase_date ) && ( $this->model )) {
        $date = date_create($this->purchase_date);
        date_add($date, date_interval_create_from_date_string($this->model->model->eol . ' months'));
        return date_format($date, 'Y-m-d');
    }
}

~~Again this is only a temporary fix. As soon as I get a dev environment setup and read over the guidelines I'll make a request to have this implemented.~~

CSAS-Nicholas-Roberts avatar Apr 26 '19 18:04 CSAS-Nicholas-Roberts

Is this new behavior? Because I updated my install to v4.6.15 and now my assets cannot be listed or searched for. I can find users just fine though. Can confirm that the altered code resolved the issue, though, and assets are once again visible.

KimmoJ avatar Apr 29 '19 12:04 KimmoJ

In my case, I just started using the platform on v4.6.15 so I don't have the context of the way it worked in the version before.

CSAS-Nicholas-Roberts avatar Apr 29 '19 17:04 CSAS-Nicholas-Roberts

Ok so it looks like this got fixed in a patch made a few days ago. I must have missed it when I did the original pull.

If you installed via git, do a git pull to fix the problem.

Related Issue #6922 - Updated my previous comment on the fix

CSAS-Nicholas-Roberts avatar Apr 29 '19 17:04 CSAS-Nicholas-Roberts

I'm getting this error, but at a different line:

[2019-04-29 12:05:38] production.ERROR: ErrorException: date_interval_create_from_date_string(): Unknown or bad format ( months) at position 0 (m): The timezone could not be found in the database in /var/www/snipe-it/app/Presenters/AssetPresenter.php:496 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'date_interval_c...', '/var/www/snipe-...', 496, Array) #1 /var/www/snipe-it/app/Presenters/AssetPresenter.php(496): date_interval_create_from_date_string(' months') #2 /var/www/snipe-it/app/Http/Controllers/ReportsController.php(652): App\Presenters\AssetPresenter->warrantee_expires() #3 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(39): App\Http\Controllers\ReportsController->App\Http\Controllers{closure}(Object(Illuminate\Database\Eloquent\Collection)) #4 /var/www/snipe-it/app/Http/Controllers/ReportsController.php(699): Illuminate\Database\Eloquent\Builder->chunk(500, Object(Closure)) #5 /var/www/snipe-it/vendor/symfony/http-foundation/StreamedResponse.php(114): App\Http\Controllers\ReportsController->App\Http\Controllers{closure}()

twisted3motions avatar Apr 29 '19 19:04 twisted3motions

    $date = date_create($this->purchase_date);
    date_add($date, date_interval_create_from_date_string($this->warranty_months . ' months'));
    return date_format($date, 'Y-m-d');

twisted3motions avatar Apr 29 '19 19:04 twisted3motions

What is the result of the error? Same thing? Assets not appearing?

Have you already pulled down a recent copy of the last release?

CSAS-Nicholas-Roberts avatar Apr 29 '19 19:04 CSAS-Nicholas-Roberts

Just appears when trying to get a custom report. This fixed it: UPDATE assets SET warranty_months = 0 WHERE warranty_months IS NULL

twisted3motions avatar Apr 29 '19 19:04 twisted3motions

Is this still relevant? We haven't heard from anyone in a bit. If so, please comment with any updates or additional detail. This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Don't take it personally, we just need to keep a handle on things. Thank you for your contributions!

stale[bot] avatar Jun 28 '19 20:06 stale[bot]

This issue has been automatically closed because it has not had recent activity. If you believe this is still an issue, please confirm that this issue is still happening in the most recent version of Snipe-IT and reply to this thread to re-open it.

stale[bot] avatar Jul 05 '19 21:07 stale[bot]

same issue - i can custom export it - but cant see in asset list

[2024-06-05 00:00:02] production.ERROR: Attempt to read property "alert_interval" on null {"exception":"[object] (ErrorException(code: 0): Attempt to read property "alert_interval" on null at /var/www/html/snipeit/app/Console/Commands/SendExpirationAlerts.php:45) [stacktrace] #0 /var/www/html/snipeit/app/Console/Commands/SendExpirationAlerts.php(45): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\SendExpirationAlerts->handle() #2 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #3 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure() #4 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod() #5 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call() #6 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call() #7 /var/www/html/snipeit/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute() #8 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run() #9 /var/www/html/snipeit/vendor/symfony/console/Application.php(1040): Illuminate\Console\Command->run() #10 /var/www/html/snipeit/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand() #11 /var/www/html/snipeit/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun() #12 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run() #13 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()

SFazeem avatar Jun 13 '24 15:06 SFazeem