Back to the index page  
LiveChat! (0 online)   FAQ   Search   Memberlist   Usergroups   Register   Profile   Log in to check your private messages   Log in 
task()->check() and task_priority

 
Post new topic   Reply to topic    web2Project Forum Index » Developer Break Room View previous topic :: View next topic  
task()->check() and task_priority
 PostPosted: Mon Feb 01, 2010 8:11 pm Reply with quote  
Message
  opto
Evangelist Member

Joined: 30 Jan 2010
Posts: 191
Location: Germany
If I create a new task in PHP and set priority to 0:

Code:

$obj = new CTask();
$obj->task_id=0;
$obj->task_parent=0;
$obj->task_priority=0;
$obj->task_owner = $AppUI->user_id;
$obj->task_project=2;
$obj->task_name='test';
$obj->task_duration=1;
$obj->task_end_date='2010-01-01 08:00:00';
$obj->task_start_date='2010-01-01 09:00:00';




 $result = $obj->store($AppUI);


then ::task->check() which is called in store() throws an error in

Code:


      if ($this->task_priority == '') {
         $errorArray['task_priority'] = $baseErrorMsg . 'task priority is NULL';


is that as intended?

If I set task_priority to 1,2, no problem.

Now, I see many entries in the db where task_priority == 0. How do they get there? My background is C++, so wrong understanding of PHP?

Thanks for any help,

Klaus
View user's profile Send private message
 PostPosted: Mon Feb 01, 2010 10:40 pm Reply with quote  
Message
  opto
Evangelist Member

Joined: 30 Jan 2010
Posts: 191
Location: Germany
Ok, I see that this works if priority is a string:

$obj->task_priority='0';

Somewhat unexpected. Could it allow to import nonsense (projectimporter?? - like task_priority='yesterday'?). Maybe it should test on numeric and the range given in the system?

The following claims to work with 0 and '0':

Code:

in cases when "0" is not intended to be empty, here is a simple function to safely test for an empty string (or mixed variable):


function _empty($string){
     $string = trim($string);
     if(!is_numeric($string)) return empty($string);
     return FALSE;
}
 


from
Quote:
http://php.net/manual/de/function.empty.php


Klaus
View user's profile Send private message
 PostPosted: Mon Feb 01, 2010 11:52 pm Reply with quote  
Message
  caseydk
Administrator

Joined: 07 Nov 2007
Posts: 1348
Location: Austin, TX
I just came to the same conclusion, I was testing it to be sure. I believe when this goes to do the insert, it casts it to an int so anything like 'yesterday' would become zero (0).

Obviously this is not the intended behavior. Could you log this as a bug against v1.3 - http://bugs.web2project.net/ - and attach notes whereever you find instances of this?

Thanks. Smile

_________________
D. Keith Casey, Jr.
Blog: http://CaseySoftware.com/blog
Company: http://BlueParabola.com/

Core web2project contributor
Maintainer: Microsoft Project Importer and TodoList Module
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Post new topic   Reply to topic    web2Project Forum Index » Developer Break Room

Page 1 of 1
All times are GMT

Display posts from previous:

  

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2002 phpBB Group
Macinscott 2 by Scott Stubblefield

Get web2Project at SourceForge.net. Fast, secure and Free Open Source software downloads