Storing wwwroot in the database: possible implications

Bug #780177 reported by Ruslan Kabalin
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Confirmed
Low
Unassigned

Bug Description

Basically this issue comes from bug #684190. Are there any implications of impossibility to change wwwroot once it is stored in the database? In the hostname change wiki manual we suggest people to clear this variable manually in the database which is somewhat complicated. In addition, protocol changes (upgrade to using https or downgrade to http) might not be considered as hostname change by the user, so database config variable will be left in inconsistent state.

Do we need to keep it in the database for specific reason (e.g. comment says it used by cron, I did not quickly find where exactly)?

Tags: wwwroot
summary: - wwwroot database storage implications
+ Storing wwwroot in the database: possible implications
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

This looks like the relevant problem: http://mahara.org/interaction/forum/topic.php?id=3509

Changed in mahara:
milestone: none → 1.4.0
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

I'm pretty sure it's only in the db because it's optional in config.php, and when it's automatically guessed by init.php, it's good to store it somewhere so you don't have to do all the messing around regenerating it again on every little request.

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

I think this may be related to the error I found in bug #778272
https://bugs.launchpad.net/mahara/+bug/778272

Basically if an error was displayed to the screen before wwwroot was loaded from the database it developed errors further on.
I didn't test what the effect of this was postinstall, but definitely a problem during install (as most users won't know the default admin password)

Myself I would say that we should make wwwroot compulsory, or just cope with the working it out each time.

This is because it is a hard task for users to play about with databases just to change the setting,
and there is a possible bug with it being there (not seen much though)

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

I did some quick grepping, cron doesn't seem to rely on wwwroot being in the database at all. The only time it is read directly from the database is when it initially reads everything.

I may of missed something though.

Cheers,

Hugh

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

Had a crazy thought. It could be done by doing this.

If not in config.php, autogen and try to write back to config.php (if it is writeable by www-data)
Don't put in db

Then when people need to change site, they change in config.php

This means the autogen should only happen once, users only have to modify changes in one place (or can remove the entry in config.php to get autogen to trigger again)

The downside, if config.php isn't writable, then the autogen will trigger for every request.

Cheers,

Hugh

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Hugh, config.php is normally in the document root, which shouldn't be writable by the webserver.

I don't think anyone's claiming cron needs wwwroot to be in the db, though I noticed that comment in init.php about wwwroot (either in db or config file) being needed by cron. That comment's true but out of date though, nearly everything needs wwwroot these days, though nothing cares whether it's in config.php or in the db.

Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

I do not think really that generating it each time is significant overhead, there are just some variable checks and string functions. I will test it with profiler tomorrow. Perhaps we might get rid of storing it in the database.

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Yep, personally I don't think having it in the db is a big deal, but I'm not too fussed about making it compulsory in config.php either.

I should say though, we currently get very very few people who change sites and then complain on the forums about their wwwroot being broken. But way back before Nigel added that automatic generation, we got lots of people, mostly on shared hosts, who wrote to the forums because they couldn't work out what their wwwroot was.

Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

> I will test it with profiler tomorrow.

wwwroot generation takes about 2ms, which is merely nothing. I suggest to generate it on every run (if it is not set in the config file of course). Any objections?

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

i would agree

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Go for it. Do we care about removing wwwroot from the db on existing sites?

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

would probably be the best, otherwise we may run into issues later down the track when users try and follow old documentation that says change it in database, etc.

Cheers,

Hugh

Changed in mahara:
status: New → Confirmed
importance: Undecided → Low
milestone: 1.4.0 → none
Changed in mahara:
assignee: nobody → Ruslan Kabalin (ruslan-kabalin)
tags: added: bite-sized
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

Richard, why did you change milestone? Do you think this is too dangerous to add it into master just before the release?

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Nope, just thought it wasn't particularly high priority.

We want to make sure the release isn't held up because of stuff like this, but it's fine if it goes in.

Changed in mahara:
status: Confirmed → In Progress
Changed in mahara:
status: In Progress → Fix Committed
milestone: none → 1.4.0
Changed in mahara:
assignee: Ruslan Kabalin (ruslan-kabalin) → François Marier (fmarier)
status: Fix Committed → In Progress
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

Given that we are reverting it for now, we probably should make db variable used for cron only and update it automatically it if user has changed the host address.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/302
Committed: http://gitorious.org/mahara/mahara/commit/872bd80eec2fb5070d38ad682379664d71bf45fe
Submitter: Richard Mansfield (<email address hidden>)
Branch: 1.4_STABLE

commit 872bd80eec2fb5070d38ad682379664d71bf45fe
Author: Francois Marier <email address hidden>
Date: Thu Jun 9 18:43:23 2011 +1200

    Revert "Remove wwwroot from the database (bug #780177)"

    This reverts commit fb38dd955ceed3601da954dd5b2e55b682e1ac03.

    It turns out that we do need the wwwroot to be in the database
    because the code that sends forum posts via email runs in php
    cli mode and is needs to get the hostname of the site to embed
    in the headers.

    While not specifically mentioned in bug #794490, it was spitting
    out warnings in the logs.

    Conflicts:

     htdocs/lib/db/upgrade.php
     htdocs/lib/version.php

    Change-Id: Icb734f939889453e80b53647748976648ee18419
    Signed-off-by: Francois Marier <email address hidden>

Changed in mahara:
status: In Progress → Confirmed
milestone: 1.4.0 → none
assignee: François Marier (fmarier) → nobody
Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/379
Committed: http://gitorious.org/mahara/mahara/commit/5266d1b4406cfdad86a57b2080910319ba9ad883
Submitter: Richard Mansfield (<email address hidden>)
Branch: master

commit 5266d1b4406cfdad86a57b2080910319ba9ad883
Author: Francois Marier <email address hidden>
Date: Thu Jun 9 18:43:23 2011 +1200

    Revert "Remove wwwroot from the database (bug #780177)"

    This reverts commit fb38dd955ceed3601da954dd5b2e55b682e1ac03.

    It turns out that we do need the wwwroot to be in the database
    because the code that sends forum posts via email runs in php
    cli mode and is needs to get the hostname of the site to embed
    in the headers.

    While not specifically mentioned in bug #794490, it was spitting
    out warnings in the logs.

    Conflicts:

     htdocs/lib/db/upgrade.php
     htdocs/lib/version.php

    Change-Id: I36b33ac72eee01f71056a45c706f2fc8674620ec
    Signed-off-by: Francois Marier <email address hidden>

tags: removed: bite-sized config
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.