View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - [API Bug] Values of SqlElements inside a SqlElements aren't fetched - ProjeQtOr
 
 

[API Bug] Values of SqlElements inside a SqlElements aren't fetched

More
21 Feb 2014 16:58 - 21 Feb 2014 17:03 #1 by Simon Tremblay
Hello,

I was trying the new API from version 4.1. I tried to retrieve progress of all of my projects and it happened that it returns to me 0. I found that progress is not a variable from Project but it is a variable from a PlanningElement that is a member variable of Project.



So I assumed that only the data for Project was retrieved from database and not the one for the other sql elements inside a Project...

You will find my attempt to fix that bug with a patch attached with this post (I work with git).

Basically, I defined a new function
getAllSqlElementsFromCriteria

We must define it for each SqlElements containing other SqlElements. Surely there is a better way to achieve that...

Here it is how I fixed Project (I know there is other SqlElements than Project that contains SqlElements but I don't use them for now):
public function getAllSqlElementsFromCriteria($critArray, $initializeIfEmpty=false, $clauseWhere=null, $clauseOrderBy=null, 
                                                $getIdInKey=false, $withoutDependentObjects=false, $maxElements=null) {
      $projects = array();
      $projects = parent::getAllSqlElementsFromCriteria($critArray, $initializeIfEmpty, $clauseWhere, $clauseOrderBy,
              $getIdInKey, $withoutDependentObjects, $maxElements);
      foreach ($projects as $project) {
        $project->ProjectPlanningElement = SqlElement::getSingleSqlElementFromCriteria('ProjectPlanningElement', array('refType'=>'Project', 'refId'=>$project->id));
      }
      
      return $projects;
  }

The patch:

File Attachment:

File Name: fix_api_bu...atch.zip
File Size:2 KB
Attachments:
Last edit: 21 Feb 2014 17:03 by Simon Tremblay.

Please Log in or Create an account to join the conversation.

More
23 Feb 2014 12:16 #2 by babynus
Hi,

Thanks for this analysis.

Your solution is a good workaround, but as you wrote, I think there is more simple.
I'll have a look.

Ticket 1306 recorded.

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
01 Mar 2014 13:55 - 01 Mar 2014 13:56 #3 by babynus
In the end, fixing is much more simple. :woohoo:
In /model/persistence/SqlElement.php, replace lines 1458 :
if (! $withoutDependentObjects) {
	$obj->getDependantSqlElement($col_name);
}
with
if (! $withoutDependentObjects) {
	$obj->$col_name=$obj->getDependantSqlElement($col_name);
}

In fact, it was a bug :(
and an old one... :blush:

Babynus
Administrator of ProjeQtOr web site
Last edit: 01 Mar 2014 13:56 by babynus.

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.034 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.