ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Relationship error

September 28, 2013 5:38am

Subscribe [3]
  • #1 / Sep 28, 2013 5:38am

    LolaLola

    3 posts

    Hi,

    I’m receiving tons of errors such as this:

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Wrong parameter count for array_unique()
    
    Filename: relationship_parser/Tree_builder.php
    
    Line Number: 135
    
    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Undefined offset: 329
    
    Filename: relationship_parser/Parser.php
    
    Line Number: 52
    
    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Undefined offset: 337
    
    Filename: relationship_parser/Parser.php
    
    Line Number: 52

    I’m running EE 2.7
    PHP Version 5.2.6-1+lenny16

    My template looks like this:

    {exp:channel:entries channel="independent_faq_page"}
               
           {parents sort="desc" orderby="title" }
           <h4><a href="#">{parents:title}</a></h4>
    <p>       <div class="accordionpanel"><br />
           {parents:faq_answer}<br />
           </div><br />
           {/parents}          <br />
          <br />
          {/exp:channel:entries}

    Strangely, this works fine on my local environment. I have the exact same files, the exact same database, but the difference is I’m running Mamp with PHP Version 5.2.17. I have tried changing the PHP version to 5.3.14 and 5.4.4 and things work ok there too.

    I can only imagine there is some bug with php version 5.2.6?

    I have edited the file expressionengine/libraries/relationship_parser/Tree_Builder.php below line 497 to echo out the entry ids like so:

    $field_id = $leaf['L'.$i.'_field'];
        $entry_id = (int) $leaf['L'.$i.'_id'];
        $parent_id = (int) $leaf['L'.$i.'_parent'];
        echo $entry_id; // <!-- Echo out entry ids

    I then visit the same page on both staging/local.

    On my staging environment the result is:

    329,337,330,338,331,339,332,340,333,341,334,342,327,335,328,336,

    On my local environment the result is:

    327,335,328,336,329,337,330,338,331,339,332,340,333,341,334,342,

    So clearly there is some disparity between the entry ids being returned on staging vs local, hence the offset errors.

    I have been doing some research and someone else has found a bug with array_unique() on one version of PHP, and there was a fix. But that doesn’t work for my version it seems. Here is that solution:

    http://ellislab.com/forums/viewthread/236495/#1058926

    Any ideas please??

  • #2 / Oct 29, 2013 4:56pm

    TheiSETGroup

    5 posts

    I am experiencing the same problem—tried the other fix, and it did not work for me either.

    The Error:

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Wrong parameter count for array_merge()
    
    Filename: relationship_parser/Tree_builder.php
    
    Line Number: 133

    My template code:

    {exp:channel:entries channel="department" dynamic="no"}
      <h3><a name="{entry_id}" class="none">{title}</a></h3>
    <p>  {career_dept}<br />
        {career_dept:parents field="career_dept"}<br />
          {if parents:no_results}NOTHING FOUND{/if}<br />
          </p><h4>{title}</h4>
    <p>      {job_description}<br />
       {/career_dept:parents}<br />
      {/career_dept}  <br />
    {/exp:channel:entries}

    PHP Version 5.2.14

     

  • #3 / Oct 30, 2013 9:20am

    Ralph

    78 posts

    It looks like that code only supports PHP 5.2.9 and above as there is a new parameter to do with sorting in that version for array_merge - http://php.net/manual/en/function.array-unique.php

    My guess with the difference with the entry_ids between staging/local is because local is working as it should but staging isn’t sorting because it’s an earlier PHP version but still working because it’s only a php warning rather than a fatal error.

    You could try upgrading to EE 2.7.1 or upgrading PHP to the latest verison on staging.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases