Moodle

Quotes mismatch leads to print "$cid" instead of the value of $cid

Details

  • Database:
    Any
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

While trying to fix MDL-14336 I came across nasty code within mod/data/lib.php that uses a mismatch of single and double quotes like this:

echo '<option value="$cid">'.$currentfield->name.'</option>';

which led not to solve $cid into its value, but printing out "$cid" to the HTML source instead. I have cleaned up the whole quotes related code within if (!empty($currentfields) && !empty($newfields)) { } and also added linebreaks after option tags to prevent making kilometers long lines of HTML code. Now the resulting table also displays properly, previously it got cut down somehow.

Issue Links

Activity

Hide
Robert Allerstorfer added a comment -

Here is the patch against MOODLE_19_STABLE. Should be committed asap, since the current code CAN'T work.

Show
Robert Allerstorfer added a comment - Here is the patch against MOODLE_19_STABLE. Should be committed asap, since the current code CAN'T work.
Hide
Petr Škoda (skodak) added a comment -

found one more in new preset class, thanks for the report and patch

Show
Petr Škoda (skodak) added a comment - found one more in new preset class, thanks for the report and patch
Hide
Robert Allerstorfer added a comment -

Thank you for committing, Petr! With this bug having fixed, I was now also able to fix bug MDL-14336

Show
Robert Allerstorfer added a comment - Thank you for committing, Petr! With this bug having fixed, I was now also able to fix bug MDL-14336
Hide
Eloy Lafuente (stronk7) added a comment -

Verified, closing. Thanks!

Show
Eloy Lafuente (stronk7) added a comment - Verified, closing. Thanks!
Hide
Robert Allerstorfer added a comment -

Petr,

I noticed that your change of mod/data/lib.php in HEAD (http://cvs.moodle.org/moodle/mod/data/lib.php?r1=1.151&r2=1.152) was not limited to the reported problem. In addition, you reverted Dongsheng's commit http://cvs.moodle.org/moodle/mod/data/lib.php?r1=1.146&r2=1.147 as part of MDL-14129. Could you please explain?

Thanks.

Show
Robert Allerstorfer added a comment - Petr, I noticed that your change of mod/data/lib.php in HEAD (http://cvs.moodle.org/moodle/mod/data/lib.php?r1=1.151&r2=1.152) was not limited to the reported problem. In addition, you reverted Dongsheng's commit http://cvs.moodle.org/moodle/mod/data/lib.php?r1=1.146&r2=1.147 as part of MDL-14129. Could you please explain? Thanks.
Hide
Dongsheng Cai added a comment -

Fixed, no worries

Show
Dongsheng Cai added a comment - Fixed, no worries

Dates

  • Created:
    Updated:
    Resolved: