Jump to content
Mike Rockett

$page->next returning NullPage erroneously

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?

Share this post


Link to post
Share on other sites

So basically you may found a bug in the previous version? :)

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By cst989
      I have a file I want to access with ajax:
      The purpose of this file is to iterate through a repeater, and get the image from each entry.
      The number of images in the image field is set to 1, and just for good measure, to return a single image.
      And my code:
      // site/ajax/processImage.ajax.php?group=1206 require_once($_SERVER['DOCUMENT_ROOT'].'/index.php'); $resourceGroup = (int) $_REQUEST['group']; // get the Repeater field $resources = $pages->get($resourceGroup)->resources; foreach ($resources as $resource) { echo $resource->title; // Works as expected echo $resource->image->url; // /site/assets/files/1259/ echo $resource->image; // filename.jpg echo $resource->image->description; // nothing } See comments above for what is output, why isn't URL giving me a full URL, and no description is available?
      If I try to access $image->size() I get the following fatal error:
      Error: Uncaught exception 'ProcessWire\WireException' with message 'Method Pageimages::size does not exist or is not callable in this context' in F:\sites\<sitename>\wire\core\Wire.php:519
       
    • By flashmaster
      Hi im new to this forum and i need some help with a booking system that i have trying to implement under Processwire. I hope that i can explain as much as i can what my problem is.
      Here is the orginal script https://github.com/olejon/phpmyreservation
      I downloaded the script and got some help to fix it because it was all messed up. I have attached a file "ReservationSystem.rar" and it should work out of the box. Also attached the database file "Phpmyreservation.sql".
      The thing is the script works great as it is now but when i install a blank version of processwire and import the script to the template folder it wont work. I have tried many things but cant get it to work just error after error etc. Please ask me if you need some more information about this. I know you are the experts so thats why im asking you.
      ReservationSystem.rar
      phpmyreservation.sql
    • By ROLAND_JUNO
      Thanks everyone who responded, Dragan helped me out and got me up and running.
       
      Thanks
      Cam
       
       
    • By ren
      Hi folks,
      My department is planning to move up to five of our employer's websites in-house and onto ProcessWire from a CMS which has not seen much development in the last few years. They're B2B magazine websites and we feel that ProcessWire would be a great fit. But there are concerns over support. I'm the only server side programmer, so what would happen were I to leave or be hit by the proverbial bus?
      So we're looking for some kind of insurance. Thinking along the lines of a support contract, covering maybe 2 hours of support time per month. With a commitment to become more involved should the need arise, so providing more support if needed to someone who takes over my role, or in the 'bus' type emergency, be willing to take over full support duties for a limited period of time.
      The 2 or so hours would be used for providing advice if I were to really get stuck. But I'm happy using the forums for help, and I've built a prototype of one of the sites without huge difficulty (go ProcessWire!), so under normal circumstances they probably won't be used.
      The five sites are all quite large (the prototype site has 40 templates and 95 fields), consisting of news sections, a jobs section, a business directory, reader polls and social media integration. Some of the sites allow membership for the business directory, so companies can login and manage their listing and upload press releases, via a custom dashboard (implemented as a Process module).
      All code will be commented and held in a git repo.
      We're located in the UK. Email support would be sufficient I think.
      If you're interested, please PM me with a rough estimate of costs for:
      The ~ 2 hours per month standard support. Full 'emergency' support of all 5 websites. Any one-off setup costs. And/or suggest an alternative pricing structure / proposal.
      Again at this stage we're just looking for a rough idea of costs and who would be available, so ballpark figures would be fine
      If you could also provide a link to your website please.
      Please let me know if you would like any further information.
      Thanks
    • By Brian Scramlin
      Hello,
      I am truly stuck. I have a website I built for a client that has become quite successful: http://drydenwire.com
      It is an independent news agency. The problem is, I built everything from scratch in Processwire and things were purring along until the traffic went up. Now, I keep getting these huge spikes which last about 15 seconds and cause all users to receive a 503 Error. I have created a public repo for review: https://github.com/scramlo/DrydenWire.com/tree/master and can answer any questions that may lead to an answer. I am willing to hire a more experienced developer if the community is unable to help me mine out this issue.
      I have gone through the usage logs and know that all traffic is legitimate, I am not getting bombarded by a spam IP address or anything like that.
      Thank you for any and all assistance as this client is getting frustrated and I would rather not lose them!!!
      -Brian


       
×
×
  • Create New...