Force Moodle to put Dataroot under website root

Had to help install Moodle today. Pretty ugly experience comparing for example to wordpress installation.

Main problem was that Moodle forces you to put dataroot directory outside of webroot directory. Not going to argue is it magic cure against all evil and bad or not, but two things are sure:

a) User needs options, and decision should be he’s (just warning should be ok, and default restricting .htaccess file)
b) If you are using some hostingserver or have some-kind setup which doesn’t allow your php script to access files outside from wwwroot, then you are in deep problems.

But, there is atleast one good solution 😀 And that’s directly related to power of open source – if you don’t like something, CHANGE IT!


* Open in your favorite editor file MOODLE_INSTALL_DIR/lib/adminlib.php
* find function is_dataroot_insecure
* add return false; directly after function header, so it looks like this

function is_dataroot_insecure($fetchtest=false) {
    return false;
    global $CFG;

it allows you to put datadir wherever you want and test or use it on your own risk.

Other problems were somehow related to installer, and seems that it thinks, that you have all power on database you ever can (in other words – you have root-like permissions). So lot of messages “table already exists” and so on. And later.. some magical message “DDL sql execution error” – whatta hek is that?

As it happes on import, it is related to creation of temporary tables. WHY can’t it be cheked in installation time or given some HUMAN-readable message. Fix it:

GRANT CREATE TEMPORARY TABLES ON `database`.* TO 'username';
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Exaptcha (all lowercase letters) reload *