Pull requests updates logic for get_post_year_range to handle an empty db. Initially set oldest post date to current year and only update if query returns a result.
Resolves issue #98 where if no posts exist oldest year is set to 1970…
…. Set the oldest year equals to the current year and updates if post_date is returned from query.
Shouldn't we return false instead of the current year when there are no posts?
Returning false would cause an exception to be thrown in "check_year_has_posts" as it uses the return value of get_post_years_range directly in a foreach statement. I've updated the branch in the pull request so that an empty array is returned and will play nice with existing code and return values for the function.
Yep, that makes sense.
update to return empty array instead of current year for no posts in db
Minor, but we can remove the else block here since the if returns.
One small comment and I think we're good to merge.
Removing else statement per feedback and standards.
@mjangda > method updated with removal of else statement. Thanks.