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

All assets disappeared (no changes were made) #6955

Closed
2 tasks done
BrandonWandon opened this issue Apr 26, 2019 · 17 comments
Closed
2 tasks done

All assets disappeared (no changes were made) #6955

BrandonWandon opened this issue Apr 26, 2019 · 17 comments
Labels

Comments

@BrandonWandon
Copy link

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

@CSAS-Nicholas-Roberts
Copy link

CSAS-Nicholas-Roberts commented Apr 26, 2019

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.

@BrandonWandon
Copy link
Author

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

@CSAS-Nicholas-Roberts
Copy link

CSAS-Nicholas-Roberts commented Apr 26, 2019

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.

@BrandonWandon
Copy link
Author

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

@CSAS-Nicholas-Roberts
Copy link

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.

@BrandonWandon
Copy link
Author

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

@CSAS-Nicholas-Roberts
Copy link

CSAS-Nicholas-Roberts commented Apr 26, 2019

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.

@KimmoJ
Copy link

KimmoJ commented Apr 29, 2019

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.

@CSAS-Nicholas-Roberts
Copy link

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
Copy link

CSAS-Nicholas-Roberts commented Apr 29, 2019

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

@twisted3motions
Copy link

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
Copy link

    $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');

@CSAS-Nicholas-Roberts
Copy link

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

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

@twisted3motions
Copy link

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

@stale
Copy link

stale bot commented Jun 28, 2019

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 stale bot added the stale label Jun 28, 2019
@stale
Copy link

stale bot commented Jul 5, 2019

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 stale bot closed this as completed Jul 5, 2019
@SFazeem
Copy link

SFazeem commented Jun 13, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants