We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11793
    • 49 Posts
    I defined a relationship in my XML like so:
    <composite alias="CpdProfile" class="CpdProfile" local="id" foreign="webuser_id" cardinality="one" owner="local" />


    And I think that having the alias set to the exact same value as class has caused problems when $xpdo->getFKDefinition is called (and the associated getAggregates and getComposites).

    Specifically, in makeform.class.php, line 497:
    $object->_relatedObjects[$classKey][$fk]

    You can see it tries to access _relatedObjects[$classKey] as an array, which it is not - it is an Object. So it throws the error:
    Cannot use object of type CpdProfile_mysql as array


    I don’t have the time to delve into the core XPDO code for a fix, so for now I’m just making sure my aliases are different to their class name.

    XPOD v1 beta 290 on MODX v1.0
    • I think by changing the alias, you are just preventing that code from even being executed, because it’s looking by class name and relatedObjects changed a long time ago to store the objects by alias. That whole section of code is invalid for the revision of xPDO you are using, and to be honest, I want to both refactor the whole class and move it out of xPDO. It really should just be a stand-alone utility class and needs versions for Evo and Revo to be fleshed out.

      For now though, I’ll try and get the actual problem resolved though so you can update to the latest xPDO without problem.

      BTW, are you actually trying to save data into the related object defined by that relationship?
        • 11793
        • 49 Posts
        I haven’t tried to save data - this is the first time I used an alias that matched a class name so it fell over before I could actually get that far.
        • Yeah, that whole MakeForm class is way out of date and really just needs to be taken out of xPDO entirely IMO anyway. I don’t have time to work on it at the moment either. Bottom line though, this has nothing to do with alias and class being the same.