TeamPass icon indicating copy to clipboard operation
TeamPass copied to clipboard

Problem updating to 3 from 2 with sk.php

Open mnehlsen opened this issue 3 years ago • 3 comments

Steps to reproduce

  1. Use sk.php for salt
  2. Upgrade from 2 to latest version 3

Expected behaviour

The upgrade should go smooth

Actual behaviour

The upgrade fails with some errors about mysql: PHP Fatal error: Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, null given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:86

I believe it is because mysqli_query is called before the database is setup somewhere around row 250.

Server configuration

Operating system: RHEL 8

Web server: Apache

Database: Mariadb

PHP version: PHP 8.0

Teampass version: 3.0.0.17

Teampass configuration file: I don't have it handy

Updated from an older Teampass or fresh install: Update from 2.1.27

Client configuration

Browser: Firefox

Operating system: MacOSX

Logs

Web server error log

[08-Jun-2022 11:32:05 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/html/TeamPass-master/includes/config/settings.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/TeamPass-master/install/upgrade_ajax.php:31
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 31
[08-Jun-2022 11:42:18 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '../includes/config/settings.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/TeamPass-master/install/upgrade_ajax.php:31
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 31
[08-Jun-2022 11:43:19 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '../includes/config/settings.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/TeamPass-master/install/upgrade_ajax.php:31
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 31
[08-Jun-2022 11:45:46 UTC] PHP Fatal error:  Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, null given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:86
Stack trace:
#0 /var/www/html/TeamPass-master/install/upgrade_ajax.php(86): mysqli_query()
#1 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 86
[08-Jun-2022 11:48:00 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/html/TeamPass-master/includes/config/settings.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/TeamPass-master/install/upgrade_ajax.php:31
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 31
[08-Jun-2022 11:48:58 UTC] PHP Fatal error:  Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, null given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:86
Stack trace:
#0 /var/www/html/TeamPass-master/install/upgrade_ajax.php(86): mysqli_query()
#1 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 86
[08-Jun-2022 11:55:21 UTC] PHP Fatal error:  Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, null given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:86
Stack trace:
#0 /var/www/html/TeamPass-master/install/upgrade_ajax.php(86): mysqli_query()
#1 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 86
[08-Jun-2022 12:10:08 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "DB_PASSWD" in /var/www/html/TeamPass-master/install/upgrade_ajax.php:55
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 55
[08-Jun-2022 12:17:46 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "DB_HOST" in /var/www/html/TeamPass-master/install/upgrade_ajax.php:56
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 56
[08-Jun-2022 12:21:56 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "DB_ENCODING" in /var/www/html/TeamPass-master/install/upgrade_ajax.php:77
Stack trace:
#0 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 77
[08-Jun-2022 12:22:42 UTC] PHP Fatal error:  Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:118
Stack trace:
#0 /var/www/html/TeamPass-master/install/upgrade_ajax.php(118): mysqli_num_rows()
#1 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 118
[08-Jun-2022 12:44:57 UTC] PHP Fatal error:  Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in /var/www/html/TeamPass-master/install/upgrade_ajax.php:388
Stack trace:
#0 /var/www/html/TeamPass-master/install/upgrade_ajax.php(388): mysqli_fetch_array()
#1 {main}
  thrown in /var/www/html/TeamPass-master/install/upgrade_ajax.php on line 388

mnehlsen avatar Jun 22 '22 13:06 mnehlsen

Please check if this file exists : /var/www/html/TeamPass-master/includes/config/settings.php

nilsteampassnet avatar Jun 25 '22 16:06 nilsteampassnet

Yes it does exist

mnehlsen avatar Jun 28 '22 07:06 mnehlsen

Hi there

we experience the same issue when upgrading.

sk.php file exists and is accessible to apache. Same goes for settings.php.

The PHP error log states an issue with null value provided to mysqli_query($dblink, XXX) on line 86 in 'install/upgrade_ajax.php' for $db_link variable.

It seems that there is an issue in the order of operations in the file 'install/upgrade_ajax.php' since the mysqli_connect function is called on line 97.

jeffchulg avatar Aug 09 '22 13:08 jeffchulg

Still have this problem, what are you waiting for, do you need anything from me?

mnehlsen avatar Apr 19 '23 12:04 mnehlsen

Hi, I have the same problem. I cannot upgrade from 2.1.27 to 3.0.x Is there any tip to move on?

Thanks, Antonio.

tonystra81 avatar Aug 25 '23 17:08 tonystra81

Anyone sort this out, I have the same issue.

aleks001 avatar Sep 06 '23 05:09 aleks001

No, not really. We finally decided to create a fresh new installation and copy passwords from legacy to new system.

jeffchulg avatar Sep 06 '23 05:09 jeffchulg

I managed to get past it, if someone has the same issue. I removed this file from my includes/config location csrfp.config.php

You might have something pointing to this file as well so check its not being utilised somehow.

This v3 of teampass seems like an absolute mess, every step of the way I run into a new issue. I'll have to sort it out myself and update the threads because it's very hard to get any assistance from the developer.

aleks001 avatar Sep 06 '23 06:09 aleks001

I did another upgrade run and removing csrp.config.php isn't the solution. This is definetly a bug and this is how i fixed it and what was happening in my case. When you click the launch or whatever button it is to log in as admin it will spin forever. When I checked the logs it was showing the errors from OP. I noticed that the settings.php file had been backed up but a new one wasn't created. I then moved the settings.php.something.bak that teampass created back to settings.php and clicked launch again. It again backed up the settings.php file but this time it created a new settings.php file. This new file was a different format so it seems like it tries to create a new format for settings.php. The only issue is when it did it for me it didn't copy over the SECUREFILE variable. So I added: define("SECUREFILE", "teampass-seckey.txt"); under the securepath variable and it started working after that. There is obviously an issue with this process that converts the old file to the new type. To make everyones life easier, here is my full new file, you can probably just create this manually and it should get you past this step

<?php
// DATABASE connexion parameters
define("DB_HOST", "YOURDBHOST");
define("DB_USER", "YOURDBUSER");
define("DB_PASSWD", "def502001ca3ad5eedb29475ab0b9ea05ad38a37c3dcb8ba7900c07a023c61029d686e010c74e39bb335cd092fc5772a73c20390ad80b7ecd7d8e631fd81e36cbss1313766d2a19e610eb36cb6186857c151ef57faf8c6d3b781e2d5");
define("DB_NAME", "teampass");
define("DB_PREFIX", "teampass_");
define("DB_PORT", "3306");
define("DB_ENCODING", "utf8");
define("DB_SSL", array(
    "key" => "",
    "cert" => "",
    "ca_cert" => "",
    "ca_path" => "",
    "cipher" => ""
));
define("DB_CONNECT_OPTIONS", array(
    MYSQLI_OPT_CONNECT_TIMEOUT => 10
));
define("SECUREPATH", "/var/www/html/teampass/includes/config");
define("SECUREFILE", "teampass-seckey.txt");
define("IKEY", "");
define("SKEY", "");
define("HOST", "");

if (isset($_SESSION['settings']['timezone']) === true) {
    date_default_timezone_set($_SESSION['settings']['timezone']);
}

Should look something like this. I've just changed my host details.

Hope this helps.

aleks001 avatar Sep 12 '23 01:09 aleks001