craigk5n / webcalendar

WebCalendar is a PHP application used to maintain a calendar for a single user or an intranet group of users. It can also be configured as an event calendar.
http://www.k5n.us/webcalendar.php
GNU General Public License v2.0
153 stars 75 forks source link

WebCalendar Upgrade: Your mysqli database named 'usr_p663408_1' is empty and needs tables created. but tables and data exists. #471

Open max951 opened 6 months ago

max951 commented 6 months ago

I tried to update from 1.3.0 to 1.9.12

System Status said:
Settings storage: includes/settings.php
Database connection: Can connect
Number of admin users: 0
WebCalendar version (installer): v1.9.12
WebCalendar version (database):
PHP version: Supported (8.1.26)

In step 'Create/Update Tables' the wizard says: Your mysqli database named 'usr_db' is empty and needs tables created.

But all tables and data from V1.3.0 already exists.

Query SELECT COUNT(*) FROM webcal_config; returnsCOUNT(*) = 163

Query SELECT COUNT(*) FROM webcal_user WHERE cal_is_admin = 'Y' returns COUNT(*) = 2

So, why System Status says Number of admin users: 0 ? And why does the wizard want to create new tables instead of upgrading from version ZZZ ?

In file "install/install_dbtables.php" line 15 is the value of variable $emptyDatabase is true. I think it should be false. But I can can not figure out why this is so.

max951 commented 6 months ago

Perhaps this will lead someone to the solution:

If I activate line 344 in the file includes/dbi4php.php echo "Error: " . $e->getMessage() . "<br>"; I get the message Error: No database selected

But in the step before Create Database the correct database is displayed: Your mysqli database named 'usr_p663408_1' exists. You may go on to the next step.

max951 commented 6 months ago

I've done the trick: In file includes/dbi4php.php i added a line with "select_db($db_connection_info['database'])" at line 340

before:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

after:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $GLOBALS['db_connection']->select_db($db_connection_info['database']);
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

It would be fine, if someone could add this into the master.

Thanks

s22-tech commented 5 months ago

Good catch, Max! This worked for me, as well. I can't believe that anybody (running MySQL) has been able to install this script. The only error message I received was "Error executing query" which didn't help at all.

Thank you!

mada0068 commented 4 months ago

Worked for me!!!! Thanks

I've done the trick: In file includes/dbi4php.php i added a line with "select_db($db_connection_info['database'])" at line 340

before:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

after:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $GLOBALS['db_connection']->select_db($db_connection_info['database']);
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

It would be fine, if someone could add this into the master.

Thanks