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

Migrated install to new server, throwing error on login #619

Closed
dfiel opened this issue Mar 12, 2017 · 17 comments
Closed

Migrated install to new server, throwing error on login #619

dfiel opened this issue Mar 12, 2017 · 17 comments

Comments

@dfiel
Copy link

dfiel commented Mar 12, 2017

Hello,

I recently migrated my Firefly install and database to another server, by exporting the database and importing it, and copying over the firefly directory from the old server to the new one.

When trying to log in, I get this message:

Type error: number_format() expects parameter 2 to be integer, null given

Full stack trace here:
https://gist.github.com/dfiel/7e1e3c0c708dfa8a007c3f692589e5a3

What would cause this?

Thanks,
dfiel

@JC5
Copy link
Member

JC5 commented Mar 12, 2017

In your database, open the table transaction_currencies. It should have the field decimal_place, right below symbol.

If it's there, check if the rows in the table have a value in this row. If not, or when it's NULL, fill in the number 2.

@dfiel
Copy link
Author

dfiel commented Mar 12, 2017

My database looks like this:
image

I still get the error as soon as I log in.

@JC5
Copy link
Member

JC5 commented Mar 12, 2017

Alright, run the following commands to clear all caches and what-not:

php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan twig:clean
php artisan view:clear

Otherwise I have no idea, the code as far as I can trace it back includes the field you seem to be missing (hence the NULL).

The error you post refers to a file in /views/twig/. The one with the long name. If the error persists, include this file as well if you would.

@dfiel
Copy link
Author

dfiel commented Mar 13, 2017

I ran those commands, and they all completed except for php artisan twig:clean.

It gives this output:
image

Trying to access Firefly gives the same error.

I tried to find the twig folder it references, but the folder seems to be empty:
image

@JC5
Copy link
Member

JC5 commented Mar 14, 2017

Well that's good, view:clear must have taken care of that.

Your stacktrace refers to a file in this directory: /storage/framework/views/twig/b5/...

If the error occurs again, please post the content of this file too.

@dfiel
Copy link
Author

dfiel commented Mar 14, 2017

I can't post the content of the file, as the file no longer exists.

@JC5
Copy link
Member

JC5 commented Mar 14, 2017

So the problem is fixed?

@dfiel
Copy link
Author

dfiel commented Mar 14, 2017

No, I get the exact same error when logging in.

@JC5
Copy link
Member

JC5 commented Mar 14, 2017

The folder /storage/frameworks/views should be filled again. The stack trace will point to a (new) twig file.

@dfiel
Copy link
Author

dfiel commented Mar 14, 2017

Here is the contents of the php file.

JC5 added a commit that referenced this issue Mar 15, 2017
@JC5
Copy link
Member

JC5 commented Mar 15, 2017

Ok, I think I found it but I need your help to debug it.

Find the file app/Support/Amount.php and go to line 262.

Replace the content between the brackets (so between { and }) with the following code:

        $cache = new CacheProperties;
        $cache->addProperty('getDefaultCurrency');
        if ($cache->has()) {
            return $cache->get(); // @codeCoverageIgnore
        }
        $currencyPreference = Prefs::get('currencyPreference', config('firefly.default_currency', 'EUR'));
        $currency           = TransactionCurrency::where('code', $currencyPreference->data)->first();

        if (is_null($currency)) {
            throw new FireflyException(sprintf('No currency found with code "%s"', $currencyPreference->data));
        }

        $cache->store($currency);

        return $currency;

If you are unsure what to do, this is what the function should look like.

After you have done so, run these commands to clear the caches:

php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

Then, try again.

@dfiel
Copy link
Author

dfiel commented Mar 16, 2017

I downloaded the new Amount.php from the link you posted onto the server, ran the commands, and I get the same error.

JC5 added a commit that referenced this issue Mar 16, 2017
@JC5
Copy link
Member

JC5 commented Mar 16, 2017

Alright, here's a version with a lot of debug commands. Replace the content of Amount.php with this version, and also open your .env file and set APP_LOG_LEVEL to debug.

Then, run the cache clearing commands again. When the error occurs again, the error in the log file should be preceded by a lot of debug information. Could you post that information?

@JC5
Copy link
Member

JC5 commented Mar 16, 2017

File was updated slightly just now.

@dfiel
Copy link
Author

dfiel commented Mar 18, 2017

Sorry that I didn't get back to you earlier.

I uploaded the new Amount.php, cleared the cache, and now I'm able to log in! Seems like whatever you did fixed it. I'm going to mess around with it this weekend and see if I run into any more problems.

@dfiel dfiel closed this as completed Mar 18, 2017
@dfiel dfiel reopened this Mar 18, 2017
@dfiel
Copy link
Author

dfiel commented Mar 18, 2017

Just took a closer look at the page, and it seems like some graphs aren't loading.

Budgets and Spending looks like this:
image

and the Dev Console shows this:
image

@JC5
Copy link
Member

JC5 commented Mar 18, 2017

Try a hard refresh, clearing your browser cache. Depending on your previous version, you may have some old JS in your cache.

@JC5 JC5 closed this as completed Apr 8, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants