Skip to content

ZCiCalNode::addNode() incorrectly handles multiple nodes with same name #5

@pbiron

Description

@pbiron

Consider the following code:

$ical = new ZCiCal();
$vevent = new ZCiCalNode( 'VEVENT', $ical->curnode );
$vevent->addNode( new ZCiCalDataNode( 'RDATE:20180310' ) );
$vevent->addNode( new ZCiCalDataNode( 'RDATE:20180324' ) );
$ical-export();

The above results in output like:

BEGIN:VCALENDAR
PRODID:-//ZContent.net//ZapCalLib 1.0//EN
VERSION:2.0
BEGIN:VEVENT
RDATE:20180324
RDATE:20180324
END:VEVENT
END:VCALENDAR

which is incorrect: notice that both RDATE nodes in the output contain the value of last RDATE node added.

The correct output should be:

BEGIN:VCALENDAR
PRODID:-//ZContent.net//ZapCalLib 1.0//EN
VERSION:2.0
BEGIN:VEVENT
RDATE:20180310
RDATE:20180324
END:VEVENT
END:VCALENDAR

I've got a fix to ZCiCalNode::addNode() that results in the correct output for this particular case. I can submit a PR. However, since I'm really new to writing code to generate iCalendar feeds I'm not sure whether my fix will break other cases, and since you don't have any unit tests it's hard for me to tell.

Should I submit the PR anyway?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions