Menu

Reason of the 'GetRelationsQueries' method

schirrms
2019-10-18
2021-04-06
  • schirrms

    schirrms - 2019-10-18

    Hi,

    I hope that this is a silly question (!)

    I frequently find this method, when I 'search inspiration' in itop base module or complementary extensions :

            <method id="GetRelationQueries">
              <comment>/**
         * Placeholder for backward compatibility (iTop &lt;= 2.1.0)
         * in case an extension attempts to redefine this function...    
         */</comment>
              <static>true</static>
              <access>public</access>
              <type>Overload-DBObject</type>
              <code><![CDATA[   public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
            </method>
    

    I must admit, I don't understand the use of this specific function. I don't even fully understand what the parent is in that case.

    can somebody explain me that ?

    TIA,

    Pascal

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2019-10-18

    Parent refers to the parent class of the object for which you find this method.

    Impact/depends on was coded differently in the past; so it's more a sort of legacy method for compatibility issues.

     
  • Pierre Goiffon

    Pierre Goiffon - 2019-10-22

    Hello,

    The GetRelationQueries method is defined in DBObject :
    https://github.com/Combodo/iTop/blob/f271606e5e71ffbab752446d7f285ac52f4227b9/core/dbobject.class.php#L4322

    Overriding a method just to call its parent seems quite silly.
    There are lots of such overrides in the default datamodel, I can't understand why. As Jeffrey said, sure there are some historical reasons behind this...

     
  • Pierre Goiffon

    Pierre Goiffon - 2019-10-22

    After a little chat with one of Combodo's founder and some git digging : those methods were present before iTop 2.2 as there was no other way to define objects impact relations. In 2.2 was introduced the possibility to define relations in XML - but the methods overrides were left as removing would mean breaking some customizations.

    This was announced in the 2.2 migration notes : it's what we now call a depreciation. Second phase of this is removal, and this will be done in 2.8 thanks to your report :)

    Thanks Pascal !

     
  • schirrms

    schirrms - 2019-10-23

    Hi Pierre,

    Good if I could help :) :) :)

    More seriously, I understand that there is no need to religiously copy this part of code in a contribution who has in it's dependencies 'itop-config-mgmt/2.5.0'

    Good for me !

    Thanks for this deep research,

    Pascal

     
  • Pierre Goiffon

    Pierre Goiffon - 2021-04-06

    I can confirm removal was done in 3.0.0-beta :)

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.