Update from 1.5 to 1.6 can't connect to DB

I have been running IP 1.5 with PHP 7.4 for quite some time.
I upgraded from Ubuntu 20.04 to 22.04 running PHP 8.1
After upgrading Linux, I tried upgrading to IP 1.6 by following the instructions here:
https://wiki.invoiceplane.com/en/1.6/getting-started/updating-ip

So I open the setup url, and go up to the point where it asks me for database details.
I’m actually not sure why that is needed, since the config-file already has my database details. Nevertheless I enter them (correctly), but it says it can’t connect.
How come, what to do? All my other websites correctly connect to their databases, so this is not a problem on database side.

For the moment I temporarily rolled back to IP 1.5 in combination with PHP 7.4 on this server (whilst my other website stay on PHP 8.1) and that works fine.

A PHP Error was encountered

Severity: Warning
Message: Trying to access array offset on value of type bool
Filename: mysqli/mysqli_driver.php

Line Number: 128
Backtrace:

File: /var/www/redacted/application/third_party/MX/Loader.php
Line: 180
Function: DB

File: /var/www/redacted/application/core/Base_Controller.php
Line: 56
Function: database

File: /var/www/redacted/application/core/User_Controller.php
Line: 29
Function: __construct

File: /var/www/redacted/application/core/Admin_Controller.php
Line: 26
Function: __construct

File: /var/www/redacted/index.php
Line: 329
Function: require_once
A PHP Error was encountered

Severity: Warning
Message: mysqli::real_connect(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO)
Filename: mysqli/mysqli_driver.php
Line Number: 211

Backtrace:
File: /var/www/redacted/application/third_party/MX/Loader.php
Line: 180
Function: DB

File: /var/www/redacted/application/core/Base_Controller.php
Line: 56
Function: database

File: /var/www/redacted/application/core/User_Controller.php
Line: 29
Function: __construct

File: /var/www/redacted/application/core/Admin_Controller.php
Line: 26
Function: __construct

File: /var/www/redacted/index.php
Line: 329
Function: require_once
A Database Error Occurred

Unable to connect to your database server using the provided settings.
Filename: core/User_Controller.php
Line Number: 29

Go to your ipconfig.php and put (for now) single quotes around your database password.
Then re-try the upgrade.

If your password contains single quote, then surround the whole password with double quotes

v1.6 works on both PHP 7.4 and 8.1 so you won’t need to do the downgrading/upgrading dance.
Make 1.6 work on PHP 7.4 and after that upgrade to PHP 8.1

For v1.6 and PHP 7.4 you just need to remove vendor directory and composer.lock
After that run composer install.

The difference between v1.5 and v1.6 is:

Thank you. The composer-command (with PHP 7.4) seemed to work fine, but when opening IP afterwards, it says

‘Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 8.1.0”.’

If I then adjust the Virtualhost config to use PHP 8.1 instead, I see a blank page instead of the IP frontend. Server logs show

‘AH01797: client denied by server configuration’

Then I rolled back to a IP 1.5 backup (restored a folder so back to original files not affected by the above) + PHP 7.4 combi, all good again.

Let’s try the other route. I adjusted the ipconfig.php db password to having single quotes and verified that IP1.5 is still working fine. I then uploaded all files from the downloaded IP1.6 zipfile, adjust my original ipconfig.php by putting a # in front of line 1, and went to my sub.domain.xyz/index.php/setup

Then I get

composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 8.1.0”.

I adjust the Virtualhost to use PHP 8.1 and again open the setup url, then the IP installer appears. Again the DB-step fails, I see

‘Failure: cannot_connect_database_server’

I see the installer has adjusted my ipconfig.php and has removed the single quotes around the password.

If I go to the normal IP page, the error is

An uncaught Exception was encountered

Type: Error
Message: Class “mysqli_driver” not found
Filename: /var/www/redacted/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 123

Re-adding the single quotes around the password afterwards doesn’t help.

I again have put back the IP1.5 backed up folder and switched the Virtualhost to use PHP 7.4, immediately all good again.

Hope you can assist me in determining next steps, thanks in advance!

Let’s fix this one first.
After that i’ll tackle all problems 1 at a time

rm -Rf vendor
rm composer.lock
composer install

Explanation: composer.lock from the v1.6 .zip file (and the vendor directory) were created with PHP 8.1

In the end … ^^^ that is your solution.
Just make sure you get that error aboug needing PHP 8.1.
Then stick to what you have at that moment.

You’ll have PHP 7.4 with a composer.lock and vendor directory for PHP 8.1

The only thing after that is those 3 steps from my last reply

I tried but to no avail. What am I doing wrong?

  • start with a working IP 1.5
  • upload files of 1.6 zip (yesterday I forgot this step at one attempt)
  • remove composer.lock
  • remove vendor folder
  • double check ipconfig.php has commented out line number 1 and has single quotes around the password
  • run the composer command → does its thing. When opening IP1.6 I get below error
  • start the installer? → fails at the DB step ‘Failure cannot_connect_database_server’ → installer has adjusted ipconfig.php and has removed the single quotes
  • switching to PHP 8.1 no difference

An uncaught Exception was encountered

Type: Error
Message: Class “mysqli_driver” not found

After these 2 steps, take a step back and check whether you have your composer.lock PHP 8.1 error

There is 1 alternative way you can try:

  • Keep v1.5 and upgrade to PHP 8.1: I don’t know if CodeIgniter doesn’t like it or not, but I don’t think that InvoicePlane will give a message

Also compare the php.ini file of PHP 7 with PHP 8.1, an extension might not be enabled.

after these 2 steps, take a step back and check whether you have your composer.lock PHP 8.1 error

Yes it does show that message. And with my latest attempt the installer still shows the same error that it can’t connect to the database. I have switched some of my other websites from using PHP 8.2 to 8.1 and they connect to their databases using mysqli just fine.

/edit: I’m also confused why the installer asks for DB-details whilst they are already in the ipconfig.php, and why it puts the password without single quotes in the file whilst it is recommended to use single quotes.

/edit2: so if the error is not related to my database or PHP, then perhaps it is around the Virtualhost configuration of Apache. Let me dig into that soon…

1 Like

When using 1.5 against PHP8.1, the application prints a whole lot of PHP errors, deprecation warnings and so on, instead of the normal GUI. However, no database-related error.

1 Like

Perfect! Let’s think of the next step.
Check your composer.json, the codeigniter version.
is it 3.1.13 or lower?

Here is the difference between 1.5.11 and 1.6:

focus on the composer.json

Increase codeigniter version and phpdotenv version
Then run composer update

Let’s see if the number of errors decrease

Changes to my Apache virtualhost didn’t make a difference.
What should I put in the composer.json? I had just uploaded the official composer.json that is shipped with IP1.6 so that indeed has codeigniter/framework 3.1.13 and vlucas/phpdotenv 5.5

1 Like

I now tried upgrading using the exact same steps from 1.5 to 1.6.1 beta 3 (with PHP 8.1) and it went super smooth. The installer didn’t even ask me for DB details.
So according to me the problem is in the code of 1.6.
1.6.1 beta 3 runs just fine, so I’ll keep using that. Thanks for your help!

1 Like

Well… great job on solving it!
Just keep in mind, that the non-beta version is just around the corner.

Just do another diff between beta-3 and the real 1.6.1 version (it will be in the changelog in the release)

For sure, there’s a new dark theme and some tiny fixes. Also a version .sql file, i believe.

After that, you’re on the ‘real’ version and we’ll just be cruising to 1.6.2

1 Like

I uploaded the files of the final 1.6.1 yesterday, overwriting the 1.6.1 beta-3 and succesfully ran the installer afterwards.

What I notice though, is that if in IP I go to system settings - updates, it says ‘1.6’ and ‘updates available’ :thinking:

Thanks for letting us know

I think we missed updating 1 piece on the site that checks if updates are available.

Don’t worry about it for now.
This .zip is the latest version