Error adding invalid milestone

Project:ProjectPier
Version:0.8.8-alpha
Component:Code
Category:bug report
Priority:normal
Assigned:phpfreak
Status:patch - code needs review
Description

I added a milestone that was missing information, and received an error message (indicating the error report would be emailed to the administrator, but no email was generated - a separate issue). However, it created the milestone anyway. I didn't notice that and tried to create a new milestone with the same name and all required information. Same error message, but milestone was created, so now there were two with the same name. Attempting to edit either results in error but the edit actually takes place. Selecting the first one and deleting it results in error, but delete actually takes place, and thereafter, when there is only a single milestone with correct information in it, everything works as it should.

In short:
Expected behavior: When creating a milestone with any kind of invalid or missing information, system should notify user but should *not* actually create the milestone in the database.

#1

What is in cache/log.php?

#2

I think these are the relevant lines:

Session "default" started at 2011-10-07T16:39:27+0000
#1 FATAL: exception 'Exception' with message 'Call to undefined method DataObject::getDisplayName()' in /var/www/pier2/environment/classes/dataaccess/DataObject.class.php:1249
    Stack trace:
    #0 /var/www/pier2/application/controllers/MilestoneController.class.php(51): DataObject->__call('getDisplayName', Array)
    #1 /var/www/pier2/application/controllers/MilestoneController.class.php(51): Company->getDisplayName()
    #2 /var/www/pier2/environment/classes/controller/Controller.class.php(71): MilestoneController->index()
    #3 /var/www/pier2/environment/classes/controller/PageController.class.php(71): Controller->execute('index')
    #4 /var/www/pier2/environment/classes/Env.class.php(131): PageController->execute('index')
    #5 /var/www/pier2/init.php(189): Env::executeAction('milestone', 'index')
    #6 /var/www/pier2/index.php(11): require('/var/www/pier2/...')
    #7 {main}
#2 ERROR: Error: ob_end_clean(): failed to delete buffer. No buffer to delete. in '/var/www/pier2/environment/functions/general.php' on line 327 (error code: 8)
Time since start: 0.21473097801208 seconds
-------------------------------------------------------------------------------

Session "default" started at 2011-10-07T16:39:51+0000
#1 ERROR: Error: ob_end_clean(): failed to delete buffer. No buffer to delete. in '/var/www/pier2/environment/functions/general.php' on line 327 (error code: 8)
Time since start: 0.3316810131073 seconds
-------------------------------------------------------------------------------

Session "default" started at 2011-10-07T16:39:52+0000
#1 FATAL: exception 'Exception' with message 'Call to undefined method DataObject::getDisplayName()' in /var/www/pier2/environment/classes/dataaccess/DataObject.class.php:1249
    Stack trace:
    #0 /var/www/pier2/application/controllers/MilestoneController.class.php(51): DataObject->__call('getDisplayName', Array)
    #1 /var/www/pier2/application/controllers/MilestoneController.class.php(51): Company->getDisplayName()
    #2 /var/www/pier2/environment/classes/controller/Controller.class.php(71): MilestoneController->index()
    #3 /var/www/pier2/environment/classes/controller/PageController.class.php(71): Controller->execute('index')
    #4 /var/www/pier2/environment/classes/Env.class.php(131): PageController->execute('index')
    #5 /var/www/pier2/init.php(189): Env::executeAction('milestone', 'index')
    #6 /var/www/pier2/index.php(11): require('/var/www/pier2/...')
    #7 {main}
#2 ERROR: Error: ob_end_clean(): failed to delete buffer. No buffer to delete. in '/var/www/pier2/environment/functions/general.php' on line 327 (error code: 8)
Time since start: 0.22333598136902 seconds
-------------------------------------------------------------------------------

Session "default" started at 2011-10-07T16:40:05+0000
#1 ERROR: Error: ob_end_clean(): failed to delete buffer. No buffer to delete. in '/var/www/pier2/environment/functions/general.php' on line 327 (error code: 8)
Time since start: 0.29858207702637 seconds
-------------------------------------------------------------------------------

Session "default" started at 2011-10-07T16:40:05+0000
#1 FATAL: exception 'Exception' with message 'Call to undefined method DataObject::getDisplayName()' in /var/www/pier2/environment/classes/dataaccess/DataObject.class.php:1249
    Stack trace:
    #0 /var/www/pier2/application/controllers/MilestoneController.class.php(51): DataObject->__call('getDisplayName', Array)
    #1 /var/www/pier2/application/controllers/MilestoneController.class.php(51): Company->getDisplayName()
    #2 /var/www/pier2/environment/classes/controller/Controller.class.php(71): MilestoneController->index()
    #3 /var/www/pier2/environment/classes/controller/PageController.class.php(71): Controller->execute('index')
    #4 /var/www/pier2/environment/classes/Env.class.php(131): PageController->execute('index')
    #5 /var/www/pier2/init.php(189): Env::executeAction('milestone', 'index')
    #6 /var/www/pier2/index.php(11): require('/var/www/pier2/...')
    #7 {main}
#2 ERROR: Error: ob_end_clean(): failed to delete buffer. No buffer to delete. in '/var/www/pier2/environment/functions/general.php' on line 327 (error code: 8)
Time since start: 0.22391796112061 seconds

#3
Assigned to:Visitor» phpfreak
Status:new» patch - code needs review

Thanks, those where the relevant lines. Apparently you assigned the milestone to a company and as a result some code was accessed that did not exist. Here is the fix:

Edit file application/models/companies/Company.class.php
Change line

    private $completed_projects;

into

    private $completed_projects;

    /**
    * Return display name of company
    *
    * @access public
    * @param void
    * @return string
    */
    function getDisplayName() {
      return $this->getName();
    } // getDisplayName

Now things should work as expected.

#4

Thanks!