wishthis icon indicating copy to clipboard operation
wishthis copied to clipboard

Issue with the install step

Open eHonnef opened this issue 2 months ago • 3 comments

Branch

On which branch did you notice this bug?

  • [ x ] stable
  • [ x ] release-candidate
  • [ x ] develop

Description

I've build the docker image using the develop branch, stable and release and this error happens in all of them. I'm basically using the same docker compose file as the example.

I'm using a config.php mounted with the database configurations, but I cannot move forward with the installation, it is basically in this page and cannot ever connect:

Image

I've already tried to use sqlite which renders the same error. Changed the address to all possible addresses that points to the mysql database, same error.

The logs doesn't say much, there was not even an attemp to connect to the mariaDB:

2025-10-24 22:33:51 0 [Note] Plugin 'wsrep-provider' is disabled.
2025-10-24 22:33:51 0 [Note] InnoDB: Buffer pool(s) load completed at 251024 22:33:51
2025-10-24 22:33:58 0 [Note] Server socket created on IP: '0.0.0.0', port: '3306'.
2025-10-24 22:33:58 0 [Note] Server socket created on IP: '::', port: '3306'.
2025-10-24 22:33:58 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2025-10-24 22:33:58 0 [Note] mariadbd: ready for connections.
Version: '12.0.2-MariaDB'  socket: '/run/mariadb/mariadb.sock'  port: 3306  MariaDB Server

And in the wishthis container these are the latest logs:

Starting Mail Transport Agent (MTA): sendmail.
Removing user `www-data' from group `sudo' ...
Done.
[Fri Oct 24 22:35:35.657433 2025] [mpm_prefork:notice] [pid 70:tid 70] AH00163: Apache/2.4.62 (Debian) PHP/8.2.29 configured -- resuming normal operations
[Fri Oct 24 22:35:35.657593 2025] [core:notice] [pid 70:tid 70] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND'
10.0.2.100 - - [24/Oct/2025:22:36:36 +0200] "GET / HTTP/1.0" 302 340 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0"
10.0.2.100 - - [24/Oct/2025:22:36:36 +0200] "GET /index.php?page=install HTTP/1.0" 200 6789 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0"
10.0.2.100 - - [24/Oct/2025:22:36:44 +0200] "POST /index.php?page=api&module=database-test HTTP/1.0" 200 417 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0"

Is there some config that I can enable to give me more debugging logs? or if someone already had this error and manage to fix it.

Thanks.

Disclaimer

wishthis is entirely built in my free time, mostly without any pay or code contributors. While I am doing my best to help out everybody, I cannot guarantee that I will find the time or have the competence to help you out.

I greatly appreciate that you are filing a bug report, these help tremendously! Thank you!

  • [ x ] I understand that wishthis depends on volunteer work and that I am not entitled to any kind of support

eHonnef avatar Oct 24 '25 20:10 eHonnef

I just ran into the same issue. I fixed it by changing the host from "localhost" to the name of the db container. The default compose file calls it db, but I had another container with that name so I set mine as wishthis-db.

This led to another issue, saving the config got the line for the db password definition wrong, it didn't give it the definition name, only had the value. I had to manually add the name of the definition.

I also ran into issues with the non-root credentials, but with the root password I was able to get through the registration process.

greed77 avatar Nov 10 '25 19:11 greed77

Sorry, I still haven't had the time to look into this but I do not suspect a docker [configuration] issue, rather a wishthis issue. For some reason, wishthis already seems to be already installed.

https://github.com/wishthis/wishthis/blob/d78c034234b071efe459ccf7e1c6dd58ded8d8d6/src/api/database-test.php#L11-L19

grandeljay avatar Nov 11 '25 12:11 grandeljay

@greed77 I've already tried every possible connection string, 127.0.0.1, localhost, the other container ip (10.whatever), the container name (wish_db), the docker-compose string (db). But nope, it just refuses to find it.

But it is not an issue with the inter-container communication, I still can curl/ping the other container.

@grandeljay Unfortunately it is what it looks like. I don't know if it helps, i'm running the container as rootless with podman, but it shouldn't be an issue.

Is there some other log or config that I can provide that will help?

eHonnef avatar Nov 12 '25 17:11 eHonnef

@eHonnef Have you tried deleting your /config/config.php? That should solve the issue

grandeljay avatar Nov 18 '25 14:11 grandeljay

I was able to get it working by removing the bind mount to /config/config.php as suggeseted above, having the system create the config.php file for me. This did indeed allow me to get through the setup process and register a user (I was using an existing mariadb container on my server, but should work similarly for a new DB in the same stack).

In order to understand what the difference in config was, I exec'd into the container and checked out the app created config.php. Upon comparison, the main difference I noticed is that the version created by the app itself does not contain leading front slashes (/) at each define statement. That is, for example:

Should look like this:

define('DATABASE_HOST', 'mariadb');
define('DATABASE_NAME', 'wishthis');
define('DATABASE_USER', 'wishthis');
define('DATABASE_PASSWORD', 'some_not_so_random_password');

Should not look like this:

~~/define('DATABASE_HOST', 'mariadb'); /define('DATABASE_NAME', 'wishthis'); /define('DATABASE_USER', 'wishthis'); /define('DATABASE_PASSWORD', 'some_not_so_random_password');~~

The config-sample.php in both this repo and the docker repo has the forward slashes. After I checked out what was created, I copy/pasted the app created config.php into my local folder tree, created a bind mount to it in docker compose, and restarted the wishthis container. I confirmed that the app continues to work and is now reading the persistent config.php.

points-unknown avatar Nov 23 '25 06:11 points-unknown

That is interesting to read, since the forward slash is the namespace identifier in PHP and it shouldn't make a difference (in this case) whether it's set or not.

define is a native PHP function. If the forward slash is missing, PHP will attempt to find a define function in the current namespace. Since it doesn't exist, it will fallback to /define, which uses the global namespace.

See: https://www.php.net/manual/en/language.namespaces.fallback.php

grandeljay avatar Nov 23 '25 12:11 grandeljay

That is interesting to read, since the forward slash is the namespace identifier in PHP and it shouldn't make a difference (in this case) whether it's set or not.

define is a native PHP function. If the forward slash is missing, PHP will attempt to find a define function in the current namespace. Since it doesn't exist, it will fallback to /define, which uses the global namespace.

See: https://www.php.net/manual/en/language.namespaces.fallback.php

So perhaps the slashes are a red herring. But whatever made it work, the steps I took above got me there.

Thanks for the quick response!

points-unknown avatar Nov 24 '25 02:11 points-unknown

Hello all :)

So, after reading all the comments here, I've tried again and here are some observations:

  1. The config file inside the container isn't at /config/config.php it is at /var/www/html/src/config/config.php. I can confirm that because I made it work... somehow

  2. In the example config file, it uses backward slashes \.

2.1) At first I tried what @points-unknown suggested (remove the slashes completely), and... nope

2.2) Then I didn't mount the config.php file and tried to install it, like @grandeljay suggested, then... it worked.

2.2.1) Then I looked into the generated config.php, and it has the backward slashes just like the example config file.

2.2.2) Ok, fair enough, copied the generated one and then I mounted at the /var/www/html/src/config/config.php, and, now, surprisingly, it worked :)

Now, I have no clue what is the issue between installing it from scratch or mounting the config file, because I don't have any other mount point in the wishthis container, only the config.php.

BUT!!!!!

I think this is not safe to remove :)

/**
 * Channels
 *
 * It's safe to delete this if you are self-hosting. Alternatively you can
 * replace these branches and domains with your own.
 */
\define(
    'CHANNELS',
    [
        [
            'branch' => 'stable',
            'host'   => 'wishthis.online',
            'label'  => __('Stable'),
        ],
        [
            'branch' => 'release-candidate',
            'host'   => 'rc.wishthis.online',
            'label'  => __('Release candidate'),
        ],
    ]
);

this is what was different between my original config.php and the generated one.

The image is the one built locally by me using the dockerfile provided here with the develop branch, since we don't have the latest and greatest in docker hub.

eHonnef avatar Nov 24 '25 17:11 eHonnef