owncloud / tasks

:white_check_mark: Tasks app for ownCloud
GNU Affero General Public License v3.0
183 stars 44 forks source link

Fix adding of new tasks #179

Closed raimund-schluessler closed 9 years ago

raimund-schluessler commented 9 years ago

Currently new tasks are given high priority and an empty category when added. This is due to wrong initial values given at https://github.com/owncloud/tasks/blob/master/controller/taskscontroller.php#L285-L293.

Henni commented 9 years ago

I'm able to reproduce this. This can probably be fixed similarly to these changes: https://github.com/owncloud/tasks/pull/164#discussion-diff-30459929

The priority has to be fixed at this point in the code: https://github.com/owncloud/tasks/blob/master/controller/helper.php#L158

I don't like the idea of casting the priority to a string as the priority is an integer. But neither casting to an Integer ((int) $vtodo->PRIORITY) nor calling getValue() ($vtodo->PRIORITY->getValue()) works.

If I change the code to call getValue() it returns an PHP error:

Call to a member function getValue() on a non-object at \/[...]\/apps\/tasks\/controller\/helper.php#158

Even though $vtodo->PRIORITY should be a VObject-Property-Integer Object which has such a function. Any idea why this happens?

raimund-schluessler commented 9 years ago

This probably happens as it might not be set at all and then it doesn't have a getValue() function. So we always have to check if it is set or not. This bothered me a bit when upgrading to sabre 2.1 as the behaviour was different before. In #185 you check if it is set and there shouldnt be an error. Casting to int or string implicitly checks if it is set, so there is no problem.

Henni commented 9 years ago

@raimund-schluessler thanks, took me a while to find this out ;)