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.

parent orderby problem in 2.6

April 30, 2013 5:28pm

Subscribe [6]
  • #1 / Apr 30, 2013 5:28pm

    truffl's avatar

    truffl

    4 posts

    The 2.6 upgrade magically created the parents statement below.

        {parents channel="question" orderby="question_order|entry_date"}


    It throws the PHP error that you see below.

        Message: Parameter 1 to array_multisort() expected to be a reference, value given

        Filename: relationship_parser/Parser.php

        Line Number: 583


    The statement on that line does not make sense to me as it calls the array_multisort using call_user_func_array rather than directly calling it. I commented out the line and replaced it with the direct call as indicated below and it seems to work.

      //call_user_func_array(‘array_multisort’, $sort_parameters);
      array_multisort($sort_parameters);

    I am running PHP v5.3.3.

    Is this the correct fix for this problem?

  • #2 / May 13, 2013 5:25pm

    amityweb's avatar

    amityweb

    162 posts

    Where is this file please?

    I am surprised by the lack of supported fix to this, its such a visible error.

  • #3 / May 13, 2013 5:27pm

    amityweb's avatar

    amityweb

    162 posts

    I found it…

    /system/expressionengine/libraries/relationship_parser/Parser.php

  • #4 / May 16, 2013 12:08pm

    wondermade

    53 posts

    FWIW We had the same problem and the same fix worked.

    —-

    Spoke too soon.
    No matter how I adjust the settings I can’t get it to sort.

    {parents field="media-unit" orderby="entry_date" sort="desc"}
     <tr class="{switch="|gray-row"}">  
      <td class="series-episode"><a href="/media/{parents:url_title}">{exp:trunchtml chars="45"}{parents:title}{/exp:trunchtml}</a></td> 
      <td class="series-date">{parents:entry_date format="%M %j, %Y"}</td> 
      <td class="series-speaker ">{exp:trunchtml chars="20"}{parents:media-speaker}{/exp:trunchtml}</td>   
     </tr>
    {/parents}

    It has the same strangely unsorted look to it.
    You can see in the list at http://upgrade.northlandchurch.net/series/
    The list is effectively unsorted and I can’t get any sort to work. See any dumb mistakes in that code? I’ve tried orderby date, title, entry_date, etc.

  • #5 / May 16, 2013 1:46pm

    Pascal Kriete's avatar

    Pascal Kriete

    2589 posts

    There seems to be a difference between PHP 5.3 and PHP 5.4 in what is considered a valid reference in call_user_func_array(), which is probably why this wasn’t spotted. I still can’t reproduce it locally.

    Could I ask one of you to revert the above change and instead turn line ~576 into:

    $sort_parameters[] =& $columns[$v];

    Note the added ampersand. Thanks!

  • #6 / May 16, 2013 2:46pm

    wondermade

    53 posts

    That returned the error:

    A PHP Error was encountered
    Severity: Warning
    Message: Parameter 2 to array_multisort() expected to be a reference, value given
    Filename: relationship_parser/Parser.php
    Line Number: 583

    The sort doesn’t work there either.
    If it helps, orderby=“random” does work. But no other orderby seems to do anything.

  • #7 / May 16, 2013 3:08pm

    Pascal Kriete's avatar

    Pascal Kriete

    2589 posts

    The second parameter needs to be a reference?! PHP is just playing with me now.

    One more change, if you would be so kind. If that doesn’t do it I’ll spin up a vm with 5.3.3. Keeping my last change, add the same ampersand to the line below. So the two lines would look like this:

    $sort_parameters[] =& $columns[$v];
    $sort_parameters[] =& constant('SORT_'.strtoupper($sort[$i]));

    Thank you!

  • #8 / May 16, 2013 3:22pm

    wondermade

    53 posts

    No dice:

    A PHP Error was encountered
    Severity: Warning
    Message: Parameter 2 to array_multisort() expected to be a reference, value given
    Filename: relationship_parser/Parser.php
    Line Number: 584

  • #9 / May 16, 2013 3:28pm

    Pascal Kriete's avatar

    Pascal Kriete

    2589 posts

    Yeah that was my fault:

    $sort_parameters[] =& $columns[$v];
    $sort_flag = constant('SORT_'.strtoupper($sort[$i]));
    $sort_parameters[] =& $sort_flag;

    And with that - I’m going to find a PHP 5.3 box to tinker on.

  • #10 / May 16, 2013 4:25pm

    wondermade

    53 posts

    That worked! Awesome and thanks! I can now run code like:

    {parents field="media-unit" orderby="date" sort="asc"}

    And the results will sort.

    Thanks for the help!

  • #11 / May 16, 2013 4:31pm

    Pascal Kriete's avatar

    Pascal Kriete

    2589 posts

    Glad to help 😊 .

    Fix will be in the next release so no need to maintain a hack.

  • #12 / Sep 18, 2015 10:24am

    Tom Jaeger

    243 posts

    I seem to be running into a similar issue with EE 2.10.1 running on PHP 5.6.11.  I took a quick peak at the code in the relationship parser, but didn’t see a quick fix.  The following is an example of my template.

    {exp:channel:entries channel="clients" limit="1" }
     {parents field="client" orderby="title" sort="asc"}
      <h3><a href="/manager/project/{parents:url_title}">{parents:title}</a> ({title})</h3>
    <p> {/parents}<br />
    {/exp:channel:entries}

    And attached is the output.

     

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

ExpressionEngine News!

#eecms, #events, #releases