seboettg / citeproc-php

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

Call to a member function getRangeDelimiter() on null #64

Closed jonathangreen closed 5 years ago

jonathangreen commented 5 years ago

Issue

I was seeing a fatal error while calling into this library from my code:

Error: Call to a member function getRangeDelimiter() on null in Seboettg\CiteProc\Rendering\Date\Date->render()

Test cases

I have added two new test cases in this PR, both were failing previously: bugfix-github-dates-minimal.txt In this case the whole date was rendering, instead of just the datepart specified in the CSL.

--- Expected
+++ Actual
@@ @@
-'2004'
+'October 21–23, 2004'

bugfix-github-dates.txt In this case I was getting a fatal error

Error: Call to a member function getRangeDelimiter() on null in Seboettg\CiteProc\Rendering\Date\Date->render()

Fix

The fix here was two-fold, one was to ensure the part of the date range we are rendering is actually specified in the CSL, and the other is to fall back to normal date rendering if the part of the date required in the CSL is not actually part of the date range.

Additional Notes:

Any feedback on this fix would be much appreciated, I would like to see it merged into the project as this case is causing issues for one of the users of my software that calls out to this library. Also thank you for building and maintaining this very useful library.

Interested parties

@seboettg

seboettg commented 5 years ago

Hi @jonathangreen Great work! As far as I can see, it looks very good. I'll take a closer look soon. Since all tests were passed successfully, I think I can merge your changes without running in other problems. Thank you.

seboettg commented 5 years ago

@jonathangreen I did a little refactoring. If it's ok for you, I would merge the PR into master.

jonathangreen commented 5 years ago

Looks good to me!

seboettg commented 5 years ago

I still wait for an answer to another issue. But I will release in about a week.

jonathangreen commented 5 years ago

Thanks @seboettg appreciate the quick feedback / merge!