seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
75 stars 39 forks source link

Undesirable data change after rendering #58

Closed artbovboosta closed 5 years ago

artbovboosta commented 5 years ago

Please follow the general troubleshooting steps first:

Bug reports:

Object $data contains different data before and after $citeProc->render($data, "bibliography"); operation.

Full code:

$data = file_get_contents("metadata_test.json");
$data = json_decode($data);

echo '<pre>'; print_r($data); echo '</pre>';

$style = StyleSheet::loadStyleSheet('apa');
$citeProc = new CiteProc($style);
echo $citeProc->render($data, "bibliography");

echo '<pre>'; print_r($data); echo '</pre>';

The result is: image

In class Text.php, on line 106, there is "unset" operation which removes title field.

As objects are passed by references by default, I suggest to clone those objects before processing.

P.S. I noticed that this issue occurs only when "type": "webpage" and there is no authors.

Used CSL stylesheet:

apa

Used CSL metadata

[ { "URL": "www.starwars.com/", "accessed": { "date-parts": [ [ "2018", "09", "19" ] ] }, "id": "item-1", "title": "StarWars.com | The Official Star Wars Website", "type": "webpage" } ]

seboettg commented 5 years ago

Thank you for this bug report. Version 2.1.5 has been released which should solve this bug. Please close this issue if everything works properly.

artbovboosta commented 5 years ago

Everything works fine. Thanks a lot!