Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL syntax error when adjusting task end date #63

Open
cleary opened this issue May 13, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@cleary
Copy link

commented May 13, 2019

Hi @ajdonnison,
I've just completed our server migration to v2.1.9 - some env details:

CentOS Linux release 7.5.1804 (Core)
mariadb-server-5.5.60-1.el7_5.x86_64
php-7.0.32-1.el7.remi.x86_64

We've discovered our first issue - to replicate:
Edit task -> change task end date -> submit

it throws this error up:

ERROR: /data/srv/debortoli.private/dotProject.git/classes/query.class.php(636): query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = ''tasks'' OR mod_directory = ''tasks'') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'tasks'' OR mod_directory = ''tasks''' at line 1

...and the backtrace:

Backtrace:
0 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:636 dprint('/data/srv/debortoli.private/dotProject.git/classes/query.class.php',636,0,'query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = \'\'tasks\'\' OR mod_directory = \'\'tasks\'\') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'tasks\'\' OR mod_directory = \'\'tasks\'\'\' at line 1')
1 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:789 exec(1)
2 /data/srv/debortoli.private/dotProject.git/modules/system/system.class.php:212 loadResult()
3 /data/srv/debortoli.private/dotProject.git/classes/dp.class.php:512 getModuleByName('\'tasks\'')
4 /data/srv/debortoli.private/dotProject.git/classes/event_queue.class.php:101 getModuleName()
5 /data/srv/debortoli.private/dotProject.git/modules/tasks/tasks.class.php:2067 add(CTask::__set_state(array(
   'task_id' => '9302',
   'task_name' => 'Train User',
   'task_parent' => '9304',
   'task_milestone' => 0,
   'task_project' => '1031',
   'task_owner' => '12',
   'task_start_date' => '2011-01-10 08:00:00',
   'task_duration' => '1',
   'task_duration_type' => '1',
   'task_hours_worked' => '0',
   'task_end_date' => '2011-06-03 08:00:00',
   'task_status' => '0',
   'task_priority' => '0',
   'task_percent_complete' => 0,
   'task_description' => 'Give user training as required eg Basic GT use, Email, MFG, dotProject',
   'task_target_budget' => '0.00',
   'task_related_url' => '',
   'task_creator' => '12',
   'task_order' => '0',
   'task_client_publish' => '0',
   'task_dynamic' => 0,
   'task_access' => '0',
   'task_notify' => '1',
   'task_departments' => '0',
   'task_contacts' => '',
   'task_custom' => NULL,
   'task_type' => '0',
   '_reminder_list' => 
  array (
  ),
   '_reminder_sender' => NULL,
   '_default_batch_status' => NULL,
   '_tbl' => 'tasks',
   '_tbl_key' => 'task_id',
   '_permission_name' => 'tasks',
   '_error' => '',
   '_message' => NULL,
   '_query' => 
  DBQuery::__set_state(array(
     'query' => NULL,
     'table_list' => NULL,
     'where' => NULL,
     'order_by' => NULL,
     'group_by' => NULL,
     'limit' => NULL,
     'offset' => -1,
     'join' => NULL,
     'type' => 'select',
     'update_list' => NULL,
     'value_list' => NULL,
     'create_table' => NULL,
     'create_definition' => NULL,
     'include_count' => false,
     '_table_prefix' => '',
     '_query_id' => NULL,
     '_old_style' => NULL,
  )),
   '_action' => 'updated',
)),NULL,'remind',array (
  'id' => '9302',
  'type' => 'remind',
  'date' => 1557720515,
  'repeat_interval' => 86400,
  'repeat_count' => '1000',
  'batch' => true,
))
6 /data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php:148 addReminder()
7 /data/srv/debortoli.private/dotProject.git/index.php:241 require('/data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php')
ERROR: /data/srv/debortoli.private/dotProject.git/classes/query.class.php(636): query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = ''task'' OR mod_directory = ''task'') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'task'' OR mod_directory = ''task''' at line 1
Backtrace:
0 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:636 dprint('/data/srv/debortoli.private/dotProject.git/classes/query.class.php',636,0,'query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = \'\'task\'\' OR mod_directory = \'\'task\'\') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'task\'\' OR mod_directory = \'\'task\'\'\' at line 1')
1 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:789 exec(1)
2 /data/srv/debortoli.private/dotProject.git/modules/system/system.class.php:212 loadResult()
3 /data/srv/debortoli.private/dotProject.git/classes/dp.class.php:521 getModuleByName('\'task\'')
4 /data/srv/debortoli.private/dotProject.git/classes/event_queue.class.php:101 getModuleName()
5 /data/srv/debortoli.private/dotProject.git/modules/tasks/tasks.class.php:2067 add(CTask::__set_state(array(
   'task_id' => '9302',
   'task_name' => 'Train User',
   'task_parent' => '9304',
   'task_milestone' => 0,
   'task_project' => '1031',
   'task_owner' => '12',
   'task_start_date' => '2011-01-10 08:00:00',
   'task_duration' => '1',
   'task_duration_type' => '1',
   'task_hours_worked' => '0',
   'task_end_date' => '2011-06-03 08:00:00',
   'task_status' => '0',
   'task_priority' => '0',
   'task_percent_complete' => 0,
   'task_description' => 'Give user training as required eg Basic GT use, Email, MFG, dotProject',
   'task_target_budget' => '0.00',
   'task_related_url' => '',
   'task_creator' => '12',
   'task_order' => '0',
   'task_client_publish' => '0',
   'task_dynamic' => 0,
   'task_access' => '0',
   'task_notify' => '1',
   'task_departments' => '0',
   'task_contacts' => '',
   'task_custom' => NULL,
   'task_type' => '0',
   '_reminder_list' => 
  array (
  ),
   '_reminder_sender' => NULL,
   '_default_batch_status' => NULL,
   '_tbl' => 'tasks',
   '_tbl_key' => 'task_id',
   '_permission_name' => 'tasks',
   '_error' => '',
   '_message' => NULL,
   '_query' => 
  DBQuery::__set_state(array(
     'query' => NULL,
     'table_list' => NULL,
     'where' => NULL,
     'order_by' => NULL,
     'group_by' => NULL,
     'limit' => NULL,
     'offset' => -1,
     'join' => NULL,
     'type' => 'select',
     'update_list' => NULL,
     'value_list' => NULL,
     'create_table' => NULL,
     'create_definition' => NULL,
     'include_count' => false,
     '_table_prefix' => '',
     '_query_id' => NULL,
     '_old_style' => NULL,
  )),
   '_action' => 'updated',
)),NULL,'remind',array (
  'id' => '9302',
  'type' => 'remind',
  'date' => 1557720515,
  'repeat_interval' => 86400,
  'repeat_count' => '1000',
  'batch' => true,
))
6 /data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php:148 addReminder()
7 /data/srv/debortoli.private/dotProject.git/index.php:241 require('/data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php')
ERROR: /data/srv/debortoli.private/dotProject.git/classes/query.class.php(636): query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = ''tasks'' OR mod_directory = ''tasks'') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'tasks'' OR mod_directory = ''tasks''' at line 1
Backtrace:
0 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:636 dprint('/data/srv/debortoli.private/dotProject.git/classes/query.class.php',636,0,'query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = \'\'tasks\'\' OR mod_directory = \'\'tasks\'\') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'tasks\'\' OR mod_directory = \'\'tasks\'\'\' at line 1')
1 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:789 exec(1)
2 /data/srv/debortoli.private/dotProject.git/modules/system/system.class.php:212 loadResult()
3 /data/srv/debortoli.private/dotProject.git/classes/dp.class.php:512 getModuleByName('\'tasks\'')
4 /data/srv/debortoli.private/dotProject.git/classes/event_queue.class.php:101 getModuleName()
5 /data/srv/debortoli.private/dotProject.git/modules/tasks/tasks.class.php:2078 add(CTask::__set_state(array(
   'task_id' => '9302',
   'task_name' => 'Train User',
   'task_parent' => '9304',
   'task_milestone' => 0,
   'task_project' => '1031',
   'task_owner' => '12',
   'task_start_date' => '2011-01-10 08:00:00',
   'task_duration' => '1',
   'task_duration_type' => '1',
   'task_hours_worked' => '0',
   'task_end_date' => '2011-06-03 08:00:00',
   'task_status' => '0',
   'task_priority' => '0',
   'task_percent_complete' => 0,
   'task_description' => 'Give user training as required eg Basic GT use, Email, MFG, dotProject',
   'task_target_budget' => '0.00',
   'task_related_url' => '',
   'task_creator' => '12',
   'task_order' => '0',
   'task_client_publish' => '0',
   'task_dynamic' => 0,
   'task_access' => '0',
   'task_notify' => '1',
   'task_departments' => '0',
   'task_contacts' => '',
   'task_custom' => NULL,
   'task_type' => '0',
   '_reminder_list' => 
  array (
  ),
   '_reminder_sender' => NULL,
   '_default_batch_status' => NULL,
   '_tbl' => 'tasks',
   '_tbl_key' => 'task_id',
   '_permission_name' => 'tasks',
   '_error' => '',
   '_message' => NULL,
   '_query' => 
  DBQuery::__set_state(array(
     'query' => NULL,
     'table_list' => NULL,
     'where' => NULL,
     'order_by' => NULL,
     'group_by' => NULL,
     'limit' => NULL,
     'offset' => -1,
     'join' => NULL,
     'type' => 'select',
     'update_list' => NULL,
     'value_list' => NULL,
     'create_table' => NULL,
     'create_definition' => NULL,
     'include_count' => false,
     '_table_prefix' => '',
     '_query_id' => NULL,
     '_old_style' => NULL,
  )),
   '_action' => 'updated',
)),NULL,'remind',array (
  'id' => '9302',
  'type' => 'remind',
  'date' => 1557720515,
  'repeat_interval' => 86400,
  'repeat_count' => '1000',
))
6 /data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php:148 addReminder()
7 /data/srv/debortoli.private/dotProject.git/index.php:241 require('/data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php')
ERROR: /data/srv/debortoli.private/dotProject.git/classes/query.class.php(636): query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = ''task'' OR mod_directory = ''task'') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'task'' OR mod_directory = ''task''' at line 1
Backtrace:
0 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:636 dprint('/data/srv/debortoli.private/dotProject.git/classes/query.class.php',636,0,'query failed(SELECT mod_directory FROM (`modules`) WHERE permissions_item_table = \'\'task\'\' OR mod_directory = \'\'task\'\') - error was: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'task\'\' OR mod_directory = \'\'task\'\'\' at line 1')
1 /data/srv/debortoli.private/dotProject.git/classes/query.class.php:789 exec(1)
2 /data/srv/debortoli.private/dotProject.git/modules/system/system.class.php:212 loadResult()
3 /data/srv/debortoli.private/dotProject.git/classes/dp.class.php:521 getModuleByName('\'task\'')
4 /data/srv/debortoli.private/dotProject.git/classes/event_queue.class.php:101 getModuleName()
5 /data/srv/debortoli.private/dotProject.git/modules/tasks/tasks.class.php:2078 add(CTask::__set_state(array(
   'task_id' => '9302',
   'task_name' => 'Train User',
   'task_parent' => '9304',
   'task_milestone' => 0,
   'task_project' => '1031',
   'task_owner' => '12',
   'task_start_date' => '2011-01-10 08:00:00',
   'task_duration' => '1',
   'task_duration_type' => '1',
   'task_hours_worked' => '0',
   'task_end_date' => '2011-06-03 08:00:00',
   'task_status' => '0',
   'task_priority' => '0',
   'task_percent_complete' => 0,
   'task_description' => 'Give user training as required eg Basic GT use, Email, MFG, dotProject',
   'task_target_budget' => '0.00',
   'task_related_url' => '',
   'task_creator' => '12',
   'task_order' => '0',
   'task_client_publish' => '0',
   'task_dynamic' => 0,
   'task_access' => '0',
   'task_notify' => '1',
   'task_departments' => '0',
   'task_contacts' => '',
   'task_custom' => NULL,
   'task_type' => '0',
   '_reminder_list' => 
  array (
  ),
   '_reminder_sender' => NULL,
   '_default_batch_status' => NULL,
   '_tbl' => 'tasks',
   '_tbl_key' => 'task_id',
   '_permission_name' => 'tasks',
   '_error' => '',
   '_message' => NULL,
   '_query' => 
  DBQuery::__set_state(array(
     'query' => NULL,
     'table_list' => NULL,
     'where' => NULL,
     'order_by' => NULL,
     'group_by' => NULL,
     'limit' => NULL,
     'offset' => -1,
     'join' => NULL,
     'type' => 'select',
     'update_list' => NULL,
     'value_list' => NULL,
     'create_table' => NULL,
     'create_definition' => NULL,
     'include_count' => false,
     '_table_prefix' => '',
     '_query_id' => NULL,
     '_old_style' => NULL,
  )),
   '_action' => 'updated',
)),NULL,'remind',array (
  'id' => '9302',
  'type' => 'remind',
  'date' => 1557720515,
  'repeat_interval' => 86400,
  'repeat_count' => '1000',
))
6 /data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php:148 addReminder()
7 /data/srv/debortoli.private/dotProject.git/index.php:241 require('/data/srv/debortoli.private/dotProject.git/modules/tasks/do_task_aed.php')

Warning: Cannot modify header information - headers already sent by (output started at /data/srv/debortoli.private/dotProject.git/includes/main_functions.php:621) in /data/srv/debortoli.private/dotProject.git/classes/ui.class.php on line 577
@ajdonnison

This comment has been minimized.

Copy link
Contributor

commented May 13, 2019

This is a bit strange, as I can't see where the extra quotes are coming from. The code that calls getModuleByName is:

                // Class usually includes an initial C and is camel case
                // And never is multibyte, so we are safe to use the non mb_ functions.
                $class = strtolower(substr($class, 1));
                if (($mod_name = $mods->getModuleByName($class))) {
                        $this->_module_directory = $mod_name;
                        return $mod_name;
                }

I can't see how strtolower would add quotes - can you check that your version of classes/dp.class.php at around line 512 is the same?

@cleary

This comment has been minimized.

Copy link
Author

commented May 13, 2019

Thanks for the reply Adam, apologies I was in meetings all yesterday arvo -

I'm working off a fork of v2.1.9 here:
https://github.com/DeBortoliWines/dotProject

master is our production branch - the file you're looking for is here:
https://github.com/DeBortoliWines/dotProject/blob/master/classes/dp.class.php

The reason I've forked is so I could cherry pick #56 and #59 patches - that may be contributing...

I've diffed that file in my fork against your devel, they're the same:

[root@trevi dotproject]# git diff HEAD upstream/devel classes/dp.class.php
[root@trevi dotproject]#

diff against your master looks like:

[root@trevi dotproject]# git diff HEAD upstream/master classes/dp.class.php
diff --git a/classes/dp.class.php b/classes/dp.class.php
index a64e8ea..7f5f329 100644
--- a/classes/dp.class.php
+++ b/classes/dp.class.php
@@ -81,15 +81,6 @@ class CDpObject {
                return $this->_error;
        }
        /**
-        *      Clears any existing data in the current object
-        */
-       public function clear() {
-               foreach (array_keys(array_diff_key(get_object_vars($this), get_class_vars(get_class($this)))) as $k) {
-                       unset($this->$k);
-               }
-       }
-
-       /**
         *      Binds a named array/hash to this object
         *
         *      can be overloaded/supplemented by the child class
@@ -138,7 +129,6 @@ class CDpObject {
                $this->_query->addWhere($this->_tbl_key . ' = ' . $oid);
                $sql = $this->_query->prepare();
                $this->_query->clear();
-               $this->clear();
                return db_loadObject($sql, $this, false, $strip);
        } 
@cleary

This comment has been minimized.

Copy link
Author

commented May 16, 2019

thanks @Givo29

@ajdonnison Joel is a uni grad doing work with us so I asked him to have a look - can you confirm his patch is sensible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.