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.

Parse error on advanced conditional

August 05, 2011 9:44am

Subscribe [2]
  • #1 / Aug 05, 2011 9:44am

    benpbenp

    5 posts

    I get the following error for just one particular entry in a channel entries tag, EE v2.1.3:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/ben/work/goodwithfilm.com/httpdocs/admin/expressionengine/libraries/Functions.php(652) : eval()'d code on line 248

    I dug into it a bit and this is the PHP code that is trying to be eval’d:

    <?php if("Gibney follows the money to construct a mesmerising portrayal of corruption, vested "" and hi") : ?>

    Here is the relevant portion of the template.


    {if gwf_film_press_quote}
                
                <div id="film_press" class="segment">
                    
                    {gwf_film_press_quote}
                    {if "{row_count}"=="1"}
                    <ul class="press quotes">
                    {/if}
                        <li>
                            {if gwf_film_press_quote_snippet}
                            "<blockquote>{gwf_film_press_quote_snippet}</blockquote>" —
                            {/if}
                            {if gwf_film_press_quote_by}<h4>{if gwf_film_press_quote_link}<a href="http://{gwf_film_press_quote_link}">{/if}{gwf_film_press_quote_by} {if gwf_film_press_quote_stars}<span class="star_rating star_count_{gwf_film_press_quote_stars}">{gwf_film_press_quote_stars}/5</span>{/if}{if gwf_film_press_quote_link}</a>{/if}</h4><p>{/if}<br />
                        </li><br />
                    {if "{row_count}"=="{total_rows"}</ul>{/if}<br />
                    {/gwf_film_press_quote}<br />
                    <br />
                </div><br />
                <br />
                {/if}


    The line that is throwing the error is {if gwf_film_press_quote_snippet}. {gwf_film_press_quote} is a matrix field and {gwf_film_press_quote_snippet} is a text field column of the matrix.

    This is a hexdump of the value of {gwf_film_press_quote_snippet} that is causing a problem. As you can see these are all ascii characters.

    0000  47 69 62 6e 65 79 20 66  6f 6c 6c 6f 77 73 20 74   Gibney f ollows t
    0010  68 65 20 6d 6f 6e 65 79  20 74 6f 20 63 6f 6e 73   he money  to cons
    0020  74 72 75 63 74 20 61 20  6d 65 73 6d 65 72 69 73   truct a  mesmeris
    0030  69 6e 67 20 70 6f 72 74  72 61 79 61 6c 20 6f 66   ing port rayal of
    0040  20 63 6f 72 72 75 70 74  69 6f 6e 2c 20 76 65 73    corrupt ion, ves
    0050  74 65 64 20 69 6e 74 65  72 65 73 74 73 20 61 6e   ted inte rests an
    0060  64 20 68 69 64 64 65 6e  20 61 67 65 6e 64 61 73   d hidden  agendas
    0070  20 74 68 61 74 20 77 6f  75 6c 64 20 68 61 76 65    that wo uld have
    0080  20 6d 61 64 65 20 50 61  6b 75 6c 61 20 70 72 6f    made Pa kula pro
    0090  75 64 2e                                           ud.

    Just as additional confirmation, If I comment out the if block, changing

    {if gwf_film_press_quote_snippet}
        "<blockquote>{gwf_film_press_quote_snippet}</blockquote>" —
    {/if}

    to

    {!--if gwf_film_press_quote_snippet}
        "<blockquote>{gwf_film_press_quote_snippet}</blockquote>" —
    {/if--}

    The error goes away. If delete the contents of this matrix cell, the error goes away. If I delete the word “interests”, or modify it in any way, the error goes away. If I delete the entire string leaving ” interests ” (importantly, with leading and trailing spaces), the error does NOT go away.


    Digging further still I find the exact str_replace that introduces the problem. However, I find myself unable to penetrate the secrets of the prep_conditionals function, therefore my journey ends here.

    File libraries/Functions.php, function prep_conditionals, line 2828:

    $str = str_replace(array_keys($switch), array_values($switch), $str);

    Before this the surrounding template is:

    l Film {if 3.4308751212E+39}<span class="star_rating star_count_4">4/5</span>{/if}{if 3.67160555933E+39}</a>{/if}</h4>{/if}
                        </li>
                    {if 3.483842626E+39==3.43878764003E+39}</ul>{/if}
                    
                    {if 3.4308751212E+39==3.46593965166E+39}
                    <ul class="press quotes">
                    {/if}
                        <li>
                            {if "Gibney follows the money to construct a mesmerising portrayal of corruption, vested 3.61187285762E+39 and hi"}
                            "<blockquote>Gibney follows the money to construct a mesmerising portrayal of corruption, vested interests and hidden agendas that would have made Pakula proud.</blockquote>" —

    And after it is

    ema/client-9">{/if}Total Film {if "4"}<span class="star_rating star_count_4">4/5</span>{/if}{if "http://www.totalfilm.com/reviews/cinema/client-9"}</a>{/if}</h4>{/if}
                        </li>
                    {if "3"=="{total_rows"}</ul>{/if}
                    
                    {if "4"=="1"}
                    <ul class="press quotes">
                    {/if}
                        <li>
                            {if "Gibney follows the money to construct a mesmerising portrayal of corruption, vested "" and hi"}
                            "<blockquote>Gibney follows the money to construct a mesmerising portrayal of corruption, vested interests and hidden agendas that would have made Pakula proud.</blockquote>" —
                            {/if}

    The results of var_dump(array_keys($switch)); and var_dump(array_values($switch)); are

    (continued below…)

  • #2 / Aug 05, 2011 9:45am

    benpbenp

    5 posts

    The results of var_dump(array_keys($switch)); and var_dump(array_values($switch)); are

    array
      0 => string '3.47220194261E+39' (length=17)
      1 => string '3.63675063161E+39' (length=17)
      2 => string '3.45135739462E+39' (length=17)
      3 => string '3.61187285762E+39' (length=17)
      4 => string '3.53146333625E+39' (length=17)
      5 => string '3.53785494103E+39' (length=17)
      6 => string '3.4789292272E+39' (length=16)
      7 => string '3.70986302361E+39' (length=17)
      8 => string '3.45508086099E+39' (length=17)
      9 => string '3.46593965166E+39' (length=17)
      10 => string '3.61574858676E+39' (length=17)
      11 => string '3.42025222501E+39' (length=17)
      12 => string '3.71516131479E+39' (length=17)
      13 => string '3.483842626E+39' (length=15)
      14 => string '3.43878764003E+39' (length=17)
      15 => string '3.47962042309E+39' (length=17)
      16 => string '3.51395659184E+39' (length=17)
      17 => string '3.4299193271E+39' (length=16)
      18 => string '3.59193506158E+39' (length=17)
      19 => string '3.4308751212E+39' (length=16)
      20 => string '3.62313654025E+39' (length=17)
      21 => string '3.46013653655E+39' (length=17)
      22 => string '3.67160555933E+39' (length=17)
      23 => string '3.6938043685E+39' (length=16)
      24 => string '3.51276135916E+39' (length=17)
      25 => string '3.68475907604E+39' (length=17)
      26 => string '3.60649817716E+39' (length=17)
      27 => string '3.52164752731E+39' (length=17)
      28 => string '3.61198664699E+39' (length=17)
      29 => string '3.47793852365E+39' (length=17)
      30 => string '3.65692365495E+39' (length=17)
      31 => string '3.41719099588E+39' (length=17)
      32 => string '3.52375483528E+39' (length=17)
      33 => string '3.66771401236E+39' (length=17)
      34 => string '3.55759577836E+39' (length=17)
      35 => string '3.51863451558E+39' (length=17)
      36 => string '3.72837223009E+39' (length=17)
      37 => string '3.73357970929E+39' (length=17)
      38 => string '3.66789107818E+39' (length=17)
      39 => string '3.42294582222E+39' (length=17)
      40 => string '3.68653084071E+39' (length=17)
      41 => string '3.6819077178E+39' (length=16)

    and

    array
      0 => string '"Client9film"' (length=13)
      1 => string '"http://www.client9.co.uk/"' (length=27)
      2 => string '"http://www.facebook.com/client9"' (length=33)
      3 => string '""' (length=2)
      4 => string '"117"' (length=5)
      5 => string '"WldZazpFy7I"' (length=13)
      6 => string '"Nicknamed “The Sheriff of Wall Street,” Eliot Spitzer prosecuted crimes by America’s largest f"' (length=102)
      7 => string '''' (length=2)
      8 => string '"“Spitzer’s story is so fascinating because it raises eternal questions that people will always h"' (length=102)
      9 => string '"1"' (length=3)
      10 => string '"A curious insight into power at the highest levels."' (length=53)
      11 => string '"Time Out"' (length=10)
      12 => string '"http://www.timeout.com/film/reviews/89436/client-9-the-rise-and-fall-of-eliot-spitzer.html"' (length=92)
      13 => string '"3"' (length=3)
      14 => string '"{total_rows"' (length=13)
      15 => string '"2"' (length=3)
      16 => string '"A documentary about the downfall of fatcat-bothering prosecutor Eliot Spitzer is brilliantly searing"' (length=102)
      17 => string '"The Guardian"' (length=14)
      18 => string '"http://www.guardian.co.uk/film/2011/mar/03/client-9-eliot-spitzer-film-review"' (length=79)
      19 => string '"4"' (length=3)
      20 => string '"A compulsively fascinating probe of power and its dark side"' (length=61)
      21 => string '"Total Film"' (length=12)
      22 => string '"http://www.totalfilm.com/reviews/cinema/client-9"' (length=50)
      23 => string '"Gibney follows the money to construct a mesmerising portrayal of corruption, vested "' (length=86)
      24 => string '" and hi"' (length=9)
      25 => string '"Empire"' (length=8)
      26 => string '"http://www.empireonline.com/reviews/review.asp?FID=137152"' (length=59)
      27 => string '"5"' (length=3)
      28 => string '"The film lights up a complex story like a pinball machine"' (length=59)
      29 => string '"The Financial Times"' (length=21)
      30 => string '"http://www.ft.com/cms/s/2/aaff9772-44fc-11e0-80e7-00144feab49a.html#axzz1FWk3nQa2"' (length=83)
      31 => string '"http://www.guardian.co.uk/world/2011/feb/27/eliot-spitzer-wall-street-fallen-angel"' (length=84)
      32 => string '"http://www.ideastap.com/IdeasMag/the-knowledge/alex-gibney-interview"' (length=70)
      33 => string '"http://www.thejc.com/lifestyle/lifestyle-features/46154/he-could-have-been-first-jewish-presi"' (length=102)
      34 => string '"http://my.telegraph.co.uk/expat/tag/client-9-the-rise-and-fall-of-eliot-spitzer/"' (length=82)
      35 => string '"6"' (length=3)
      36 => string '"0"' (length=3)
      37 => string '"37"' (length=4)
      38 => string '"10"' (length=4)
      39 => string '"38"' (length=4)
      40 => string '"39"' (length=4)
      41 => string '"1"' (length=3)

    , respectively. Respectfully, Ben.

  • #3 / Aug 06, 2011 7:21pm

    Dan Decker

    7338 posts

    Hello benpbenp,

    Thank you for your very thorough explanation. Is there any way you can bring your ExpressionEngine installation up-to-date to version 2.2.2? EE version 2.1.3 contains a number of bugs that have been fixed in subsequent versions. If it is possible to update your EE installation, be sure to update your Matrix add-on as well. There have been a number of changes made to it also.

    I’m just curious, do non-Matrix fields deliver an error with this same conditional?

    Best,

  • #4 / Aug 10, 2011 7:29am

    benpbenp

    5 posts

    Hi Dan,

    We are certainly planning on upgrading at some point, but not necessarily right now. Does this seem like a specific bug that definitely has been fixed in the new version?

    I tried to reproduce the problem by putting the same text in different fields and then adding conditionals on those fields to the template, but no luck.

    Thanks,

    Ben

  • #5 / Aug 11, 2011 2:10pm

    Lisa Wess

    20502 posts

    Hi, benpbenp,

    Can you clarify for me, are you trying to parse fairly complicated content, including a variety of characters such as quotes, etc?

    Thank you!

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

ExpressionEngine News!

#eecms, #events, #releases