the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
981 stars 114 forks source link

2.27.3 throws exception when executed on command line on the first-time #1085

Closed leojonathanoh closed 1 year ago

leojonathanoh commented 1 year ago

Describe the bug

2.27.3 throws exception when executed on command line on the first-time fresh installation with the snappymail data directory unpopulated, whereas it worked on <= 2.27.2. Discovered in #44

Seems to be caused by dd74759adc61af9672f7da6e06d96c9ea50d501c. This prevents the config file from being generated the first time in docker #965.

To Reproduce Steps to reproduce the behavior:

php /snappymail/index.php

Expected behavior

No exception

Screenshots

On 2.27.3:

$ docker run -e DEBUG=true --rm -it  leojonathanoh/snappymail:pr-1-acf2315
+ UPLOAD_MAX_SIZE=25M
+ MEMORY_LIMIT=128M
+ SECURE_COOKIES=true
+ sed -i 's/<UPLOAD_MAX_SIZE>/25M/g' /usr/local/etc/php-fpm.d/php-fpm.conf /etc/nginx/nginx.conf
+ sed -i 's/<MEMORY_LIMIT>/128M/g' /usr/local/etc/php-fpm.d/php-fpm.conf
+ '[' true '=' true ]
+ echo '[INFO] Secure cookies activated'
[INFO] Secure cookies activated
+ echo 'session.cookie_httponly = On'
+ echo 'session.cookie_secure = On'
+ echo 'session.use_only_cookies = On'
+ echo '[INFO] Setting permissions on /var/lib/snappymail'
[INFO] Setting permissions on /var/lib/snappymail
+ chown -R www-data:www-data /var/lib/snappymail/
+ chmod 550 /var/lib/snappymail/
+ find /var/lib/snappymail/ -type d -exec chmod 750 '{}' ';'
+ SNAPPYMAIL_CONFIG_FILE=/var/lib/snappymail/_data_/_default_/configs/application.ini
+ '[' '!' -f /var/lib/snappymail/_data_/_default_/configs/application.ini ]
+ echo '[INFO] Creating default Snappymail configuration: /var/lib/snappymail/_data_/_default_/configs/application.ini'
[INFO] Creating default Snappymail configuration: /var/lib/snappymail/_data_/_default_/configs/application.ini
+ EXITCODE=
+ su - www-data -s /bin/sh -c 'php /snappymail/index.php'
+ EXITCODE=255
+ '[' -n 255 ]
+ cat /tmp/out

Fatal error: Uncaught TypeError: RainLoop\Service::Handle(): Return value must be of type bool, null returned in /snappymail/snappymail/v/2.27.3/app/libraries/RainLoop/Service.php:17
Stack trace:
#0 /snappymail/snappymail/v/2.27.3/include.php(143): RainLoop\Service::Handle()
#1 /snappymail/index.php(11): include('/snappymail/sna...')
#2 {main}
  thrown in /snappymail/snappymail/v/2.27.3/app/libraries/RainLoop/Service.php on line 17
+ exit 255

Contrast with 2.27.2 which works:

$ docker run -e DEBUG=true --rm -it leojonathanoh/snappymail:pr-1-46dc7df

Please complete the following information:

Debug/logging information Place them here (few lines) or as attachments (many lines)

Additional context Add any other context about the problem here.

leojonathanoh commented 1 year ago

hey @the-djmaze, thanks for the fix. It seems to no longer produce an exception, but the data folder is still not populated, and config file not generated:

$ docker run --rm -it leojonathanoh/snappymail:pr-1-65533f9 sh
/snappymail # apk add tree
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tree (2.0.4-r0)
Executing busybox-1.35.0-r29.trigger
OK: 105 MiB in 85 packages
/snappymail # cd /var/lib/snappymail/
/var/lib/snappymail # tree .
.
├── README.md
└── VERSION

0 directories, 2 files
/var/lib/snappymail # /entrypoint.sh 
[INFO] Secure cookies activated
[INFO] Snappymail version: 2.27.3
[INFO] Setting permissions on /var/lib/snappymail
[INFO] Creating default Snappymail configuration: /var/lib/snappymail/_data_/_default_/configs/application.ini
[INFO] Overriding values in snappymail configuration: /var/lib/snappymail/_data_/_default_/configs/application.ini
sed: /var/lib/snappymail/_data_/_default_/configs/application.ini: No such file or directory
/var/lib/snappymail # tree .
.
├── INSTALLED
├── README.md
├── SALT.php
├── VERSION
├── _data_
│   └── _default_
│       ├── configs
│       ├── domains
│       │   ├── 1ae2c02f3722.json
│       │   ├── default.json
│       │   └── disabled
│       ├── plugins
│       └── storage
├── index.html
└── index.php

6 directories, 9 files
/var/lib/snappymail # 
the-djmaze commented 1 year ago

Correct, as there is a problem due to Nextcloud crashing that conflicts here. Will try to find a workaround.

leojonathanoh commented 1 year ago

hmm ok, i guess we'll have to wait and see for a fix.

the-djmaze commented 1 year ago

This commit has changes for it https://github.com/the-djmaze/snappymail/commit/ad07c5b472276c1fd63018bdaa60f4f2be34e432

leojonathanoh commented 1 year ago

hmm let me try it

leojonathanoh commented 1 year ago

it actually works now, thanks for the fix! :)