dotProject 2.0.4/2.1.2/2.1.3 on shared hosting
22nd January 2007
Update: the same solution seems to still apply to dotProject 2.1.2; the post instructions have been modified for dP 2.1.2.
Update 2: fsmullin suggested a method to fix a similar error in index_table.php, the files_count_max cannot be found error when you click the FILES tab/menu item. His suggestion is now incorporated into the post.
Update 3: this post is still relevant for dotProject 2.1.3.
In one of my recent posts about project management software I stated the desire to extensively test dotProject 2.0.4. However, many shared hosting providers appear incompatible with dotProject: the right to CREATE TEMPORARY TABLES in MySQL is not granted, but is needed by dotProject.
Here’s sample error (2.0.4):
query failed(CREATE TEMPORARY TABLE tasks_sum SELECT task_project, COUNT(distinct task_id) AS total_tasks,
SUM(task_duration * task_percent_complete * IF(task_duration_type = 24, 8.0, task_duration_type))/
SUM(task_duration * IF(task_duration_type = 24, 8.0, task_duration_type)) AS project_percent_complete FROM `tasks` GROUP BY task_project)
For 2.1.2, sample error would be:
Table ‘tasks_total’ doesn’t exist
I tried looking for solutions, and here’s what I found…
First of all, I tried issuing the “grant” command to try enabling temporary tables:
GRANT CREATE TEMPORARY TABLES ON dot_projects.* to dot_projects@x.myserver.com;
Expectedly, this didn’t work: “access denied for user ….”.
Then I tried looking for a ready-to-apply solution. Here are the links relevant to the topic, if you happen to prefer “the source”, and not the retelling: link 1, link 2, link 3, and link 4.
However, none of the solutions described behind the links worked for me.
Here’s my solution (error fix).
To fix, instead of creating temporary tables each time they are needed (what is impossible on many shared hostings), we need to create the necessary tables once. Then, instead of dropping temporary tables, we just truncate our “static” tables.
Here’s how we proceed.
- Issue once the following MySQL statements (using, e.g., phpMyAdmin):
- CREATE TABLE IF NOT EXISTS `tasks_problems` (
- `task_project` INT( 11 ) default NULL ,
- `task_log_problem` TINYINT(1) default NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `tasks_critical` (
- `task_project` INT( 11 ) default NULL ,
- `critical_task` INT( 11 ) default NULL ,
- `project_actual_end_date` DATETIME default NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `tasks_sum` (
- `task_project` INT( 11 ) default NULL ,
- `total_tasks` INT( 6 ) default NULL ,
- `project_percent_complete` VARCHAR( 11 ) default NULL,
- `project_duration` VARCHAR( 11 ) default NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `tasks_summy` (
- `task_project` INT(11) default NULL,
- `my_tasks` varchar(10) default NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `tasks_users` (
- `task_project` INT(11) default NULL,
- `user_id` INT(11) default NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `tasks_total` (
- `task_project` INT( 11 ) DEFAULT NULL ,
- `total_tasks` INT( 6 ) DEFAULT NULL
- ) TYPE=MyISAM;
- CREATE TABLE IF NOT EXISTS `files_count_max` (
- `file_versions` INT(11) default 0,
- `file_lastversion` float default '0',
- `file_version_id` INT(11) default 0,
- `file_project` INT(11) default 0
- ) TYPE=MyISAM;
This will create all the necessary tables.
Note: tasks_total and files_count_max tables are 2.1.2-specific.
Another note: for 2.1.2, the tasks_sum table is one field shorter:- CREATE TABLE IF NOT EXISTS `tasks_sum` (
- `task_project` int(11) default NULL,
- `project_percent_complete` varchar(11) default NULL,
- `project_duration` varchar(11) default NULL
- ) TYPE=MyISAM;
- Now, in classes/query.class.php at line 393 (for dotProject 2.0.4; just search for the matching line in 2.1.2) replace this line:
- $q = 'CREATE TEMPORARY TABLE ' . $this->_table_prefix . $this->create_table;
with these:
- //$q = 'CREATE TEMPORARY TABLE ' . $this->_table_prefix . $this->create_table;
- $q = 'INSERT INTO ' . $this->_table_prefix . $this->create_table;
Now we won’t get any errors about the tables which fail to be created.
- Next, replace the following text in modules/projects/projects.class.php (lines 388-392 for 2.0.4):
- // Let's delete temporary tables
- $q = new DBQuery;
- $q->dropTemp('tasks_sum, tasks_summy, tasks_critical, tasks_problems, tasks_users');
- $q->exec();
- $q->clear();
with this code:
- // Let's delete temporary tables
- $sql = "TRUNCATE TABLE tasks_sum"; db_exec($sql);
- $sql = "TRUNCATE TABLE tasks_summy"; db_exec($sql);
- $sql = "TRUNCATE TABLE tasks_critical"; db_exec($sql);
- $sql = "TRUNCATE TABLE tasks_problems"; db_exec($sql);
- $sql = "TRUNCATE TABLE tasks_users"; db_exec($sql);
- $sql = "TRUNCATE TABLE tasks_total"; db_exec($sql);
- $q = new DBQuery;
Note: $sql = “TRUNCATE TABLE tasks_sum”; db_exec($sql); line is 2.1.2-specific.
At this point, you will no longer receive error messages while on the “projects” tab. - (this point applies to 2.1.2 only) Replace lines 222 and 223 in modules/files/index_table.php
- $r->dropTemp('files_count_max');
- $r->exec();
with:
- //$r->dropTemp('files_count_max');
- //$r->exec();
- $sql = "TRUNCATE TABLE files_count_max"; db_exec($sql);
- Optionally, if you want to improve the performance of dotProject specifically for these tables, change the ‘engine’ for the above-mentioned tables to ‘memory’. To do that, execute the following SQL statements:
- alter table tasks_problems engine=memory;
- alter table tasks_critical engine=memory;
- alter table tasks_sum engine=memory;
- alter table tasks_summy engine=memory;
- alter table tasks_users engine=memory;
- alter table tasks_total engine=memory;
- alter table files_count_max engine=memory;
This change will make MySQL keep these tables in RAM. As they are used as temporary tables, this decreases disk I/O a lot while working with dotProject. Of course, YMMV – to apply this change or not depends on where is your bottleneck.
Comments and further improvements are welcome.
May 5th, 2007 at 9:03
Thanks for your help.
It is working now.
May 5th, 2007 at 9:39
I’m glad it helped!
Since I applied the described solution, there were no other related error messages or problems, so it should work just fine.
June 21st, 2007 at 4:52
Thanks for this info. It really helped and saved me a lot of time.
January 28th, 2009 at 23:09
Thanks for your information!
I thought I would share that 2.1.2 that the index_table.php file in modules > files needs to be modified as well to fix the ‘files_count_max’ cannot be found error when you click the FILES menu item.
Create the following table:
CREATE TABLE `files_count_max` (
`file_versions` INT(11) default 0,
`file_lastversion` float default ’0′,
`file_version_id` INT(11) default 0,
`file_project` INT(11) default 0
) TYPE=MyISAM;
Change line 103 of index_table.php from:
$r->createTemp(‘files_count_max’);
to:
$r->addTable(‘files_count_max’);
comment out lines 222 and 223
//$r->dropTemp(‘files_count_max’);
//$r->exec();
Insert the following line in their place:
$sql = “TRUNCATE TABLE files_count_max”; db_exec($sql);
That should fix the file error.
January 28th, 2009 at 23:20
Thank you for sharing!
I’m rarely navigating to the Files tab, but when I tried I did get loads of error messages originating from index_table.php.
I am trying your solution now. If it works for me, I’ll add it to the post text.
January 28th, 2009 at 23:40
fsmullin,
your solution works not exactly as expected.
Following your directions exactly as written, I ended with a “No Result(s)” message instead of the list of files.
However, if I do not change line 103 from $r->createTemp(‘files_count_max’) to $r->addTable(‘files_count_max’) – the list of files is shown, and there are no errors generated (but the files_count_max table seems to stay empty).
If I just comment line 103 out, then I have that “No Result(s)” message again instead of files listing.
Do I understand it right that addTable() method is supposed to work on existing tables?
I guess that my solution for other tables (i.e. editing the exact files_count_max temporary creation query to just populate the existing table) might also work here perfectly – have to try that.
January 29th, 2009 at 0:06
I guess my solution (with no replace of line 103 in index_table.php) works because of the change I’ve introduced into query_class.php, namely:
//$q = ‘CREATE TEMPORARY TABLE ‘ . $this->_table_prefix . $this->create_table;
$q = ‘INSERT INTO ‘ . $this->_table_prefix . $this->create_table;
I only wonder why the addTable() doesn’t work for me.
February 1st, 2009 at 8:33
Hi,
This worked perfectly – I have made a .tar.gz and I can make a .patch file to post here if anyone wants to save them a little time…
February 1st, 2009 at 14:59
Mike,
you can send me the patch to really_anything at bogdan.org.ua (this is a catch-all address; attachment shouldn’t be larger than 1 MiB).
I will add your submission to the post.
Thank you.
February 19th, 2009 at 18:45
Thanks for taking a look at this. I was working with a blank database and then had to turn my attention to other things for a while. I will integrate your solution.