bertvandepoel / tabby

A friendly tool to manage debt
GNU Affero General Public License v3.0
71 stars 11 forks source link

Cannot start session when headers already sent #18

Closed acodispo closed 2 years ago

acodispo commented 2 years ago

Hello! This looks like a great tool, unfortunately I'm having some trouble getting it to work. I'm on a shared host (Dreamhost), running PHP 7.4 with MySQL 5.7.29. Tabbly is installed in a subdomain (e.g. tabby.domain.com).

The install seems to go fine. The database has tables, and a single user in users.

When I visit the home page, or try to log in, login doesn't happen (I'm redirected to /people but I just see the home page with login form), and I see the following error in my logs:

mod_fcgid: stderr: PHP Warning:  session_start(): Cannot start session when headers already sent in /home/acodispo/tabby.domain.com/resources/init.php on line 18

I also notice that a cookie is not being saved.

Any ideas? Thanks in advance!

bertvandepoel commented 2 years ago

Hi there. This is an interesting bug (or at least it sounds like a bug). I think I know what might be causing it, but I'm surprised that you're running into this. Perhaps it only causes issues when using mod_fcgid or with specific PHP configuration.

Since I'm not 100% sure how to replicate this issue, it would be nice if you could perform a basic change for me in the code to see if that resolves your issue. Based on your GitHub profile, I'm hoping you'd be able to, but if not then let me know and I will try to find another way. Could you edit index.php and swap lines 149 and 150 (so the include of resources/init.php before the include of templates/header.php). Could you let me know if that fixes the issue? If not, then let me know if you get any other errors in your logs or if any behaviour changes. Thx!

acodispo commented 2 years ago

@bertvandepoel Ah, thanks for your reply! I hadn't seen your message until just now, and I already tested the fix you suggested and have made a pull request. So please disregard my note in the PR about "whether you'd like to investigate further." :)

acodispo commented 2 years ago

My host's PHP config is probably causing the error, by the way, it is a little unorthodox. :)

bertvandepoel commented 2 years ago

No problem! I'm actually surprised that on my two setups, as well as those of other users, this is not a problem. In the past (at least when I started in the day with PHP 4), you couldn't have any output (buffered) before running session_start, clearly now it's sometimes allowed.

Thx for the PR, but I would also need to adapt init.php and I want to check if there are any similar cases out there that could cause issues, so I will probably make a commit myself if you don't mind.

Have you checked if you have any other issues on other pages?

acodispo commented 2 years ago

On 21/11/28 12:16PM, Bert Van de Poel wrote:

Thx for the PR, but I would also need to adapt init.php and I want to check if there are any similar cases out there that could cause issues, so I will probably make a commit myself if you don't mind.

No problem, that makes sense.

Have you checked if you have any other issues on other pages?

I don't see any other issues yet, I've been able to add people, activities, and recurring activities. Emails are being sent, etc.

Looks good!