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

Improve DB Installation Check (#1537) #1585

Merged
merged 2 commits into from
Feb 18, 2024
Merged

Improve DB Installation Check (#1537) #1585

merged 2 commits into from
Feb 18, 2024

Conversation

schast
Copy link
Member

@schast schast commented Feb 13, 2024

We have problems with the database check from time to time. Currently it is assumed that the database has already been initialized as soon as a config.php exists.

In most cases, the following error occurs:

PHP Fatal error:  Uncaught Error: Call to a member function fetchAll() on bool in /opt/app-root/src/adm_program/system/classes/Database.php:516
Stack trace:
#0 /opt/app-root/src/adm_program/system/classes/Database.php(442): Database->loadTableColumnsProperties()
#1 /opt/app-root/src/adm_program/system/classes/TableAccess.php(654): Database->getTableColumnsProperties()
#2 /opt/app-root/src/adm_program/system/classes/TableAccess.php(147): TableAccess->setColumnsInfos()
#3 /opt/app-root/src/adm_program/system/classes/TableAccess.php(109): TableAccess->clear()
#4 /opt/app-root/src/adm_program/system/classes/Session.php(62): TableAccess->__construct()
#5 /opt/app-root/src/adm_program/system/common.php(91): Session->__construct()
#6 /opt/app-root/src/adm_program/overview.php(18): require_once('...')
#7 {main}\n  thrown in /opt/app-root/src/adm_program/system/classes/Database.php on line 516
  127.0.0.1 "GET /adm_program/overview.php HTTP/1.1" 500 -

Therefore, the check should take place directly in the database and, if necessary, redirect to the installation page.

With the new check, the installation in the container can be significantly simplified, as most of the values are already available via the container configuration.

@Fasse: Can you please review the pull request (changes in adm_program) and test with a normal installation?

@schast schast added the docker label Feb 13, 2024
@schast schast self-assigned this Feb 13, 2024
@schast
Copy link
Member Author

schast commented Feb 13, 2024

current installation steps with Docker Container (6 steps with manually filled db options):

admidio_installation_orig_step01_installation
admidio_installation_orig_step02_connect_database
admidio_installation_orig_step03_create_organisazion
admidio_installation_orig_step04_create_administrator
admidio_installation_orig_step05_create_config
admidio_installation_orig_step06_start_installation

@schast
Copy link
Member Author

schast commented Feb 13, 2024

new installation steps with Docker Container (3 steps with automatically filled by docker env variables).

With this changes the other steps are automatically skipped since all options are already set in config file.

admidio_installation_step01_create_organization
admidio_installation_step02_create_administrator
admidio_installation_step03_start_installation

@@ -38,6 +38,15 @@
// => EXIT
}

// check for empty db and redirect to installation wizard
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to check for an empty db in every script? Why not check it only in index.php ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because in adm_program/system/common.php on Line 35 we have already the config.php loaded and opened the db connection.

@Fasse Fasse added this to the 4.3.4 milestone Feb 14, 2024
// check if installation is necessary
if (is_file('../../adm_my_files/config.php')) {
if (is_file($rootPath . '/adm_my_files/config.php')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second check here is required to make a difference between normal installation and docker installation.
With a Docker installation, it is possible that a config.php exists, but the database has not yet been initialized.

Copy link
Member

@Fasse Fasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classic installation is still working.

@schast schast merged commit 6c661e5 into Admidio:v4.3 Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants