Jump to content

$page->next returning NullPage erroneously


Mike Rockett
 Share

Recommended Posts

I think I may have stumbled into a bug, or perhaps something has changed since 2.5.3.
 
I have the following function that I refer to in order to obtain the latest journal entry, or the one after that if the latest is currently being viewed:

function journalLatestEntry($showNextIfCurrent = true)
{
	global $wire;
	$return = array(
		'page' => $wire->pages->findOne('template=journal-entry, sort=-created'),
		'isCurrent' => false
	);
	if ($showNextIfCurrent) {
		if ($wire->page->id == $return['page']->id) {
			$return['page'] = $return['page']->next;
			$return['isCurrent'] = true;
		}
	}
	return $return;
}

Unfortunately, since upgrading the dev-site to 2.6.0, next is returning NullPage erroneously as there are pages after the one returned. Perhaps something has changed with regards to the way in which findOne() works?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...