Kirby 2.2 UniNextPrev plugin seems to cause 'array_multisort()' error in collection.php

UniNextPrev plugin seems to cause:
Warning: array_multisort(): Array sizes are inconsistent in /.../kirby/toolkit/lib/collection.php on line 339

I’m the author, but obviously I’m a bit lost on this error? I think it is Kirby, but I can’t see why my code is causing the error there?
Anyone any idea?

> UniNextPrev plugin link

It’s in the header and is being called from a template

//Call uniNextPrev plugin
$uniNextPrev = uninextprev(); 

//Call header snippet with uniNextPrev plugin variables - no prev stuff as this is the homepage
snippet('header', array(
          'nextPageURL' => $uniNextPrev['nextPageURL'],
        'nextPageTitle' => $uniNextPrev['nextPageTitle']

Another quick observation that may help, it only shows when config.php has;
c::set('debug', true); set to false and it all works fine?

The link to the uninextprev plugin is broken. Could you post the link again?


Okay, so I played around with UniNextPrev, but ultimately found a simpler solution for my site which did the same thing, and I’m getting the same error here. This is the code I am using:

	<div class="2u align-center">
    <?php if($prev = $page->prevVisible()): ?>
        <a href="<?php echo $prev->url() ?>" class="button alt"><i class="fa fa-arrow-left"></i></a>
    <?php elseif(page()->parent()->hasPrev() && page()->parent()->prev()->hasChildren()): ?>
       <?php $prevPageURL = page()->parent()->prev()->children()->flip()->limit(1); ?>
        <a href="<?php echo $site->url()."/".$prevPageURL ?>" class="button alt"><i class="fa fa-arrow-left"></i></a>
    <?php endif ?>

EDIT: In addition, it happens for the “previous post” when on the first post, but then on the next post when your at the second to last post, then back to the previous post… so, whatever is causing it, is alternating?

I’m also getting the array_multisort warnings after upgrading to kirby_2.2.1 when using:


I’m not using the UniNextPrev plugin.

Same here - getting array_multisort errors after upgrading to kirby 2.2.1 - also when using:


I’ve been having the same problem. I found this on one of the templates in the kirby update folder and it has been working for me.

<nav class="nextprev cf" role="navigation">
  <?php if($prev = $page->prevVisible()): ?>
  <a class="prev" href="<?php echo $prev->url() ?>">&larr; previous</a>
  <?php endif ?>
  <?php if($next = $page->nextVisible()): ?>
  <a class="next" href="<?php echo $next->url() ?>">next &rarr;</a>
  <?php endif ?>

I’ve pushed a fix for this to the develop branch on github yesterday. Will release 2.2.2 either today or on Monday. Sorry for the issue

Hi @bastianallgeier, I just updated my local Kirby install with the prev/next fix from the develop branch, but although I don’t get the ‘array_multisort’ warning anymore, I do get array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } warnings on the page where I have $page->hasNextVisible() or $page->nextVisible() checks (including in the pagination). Any ideas?

Would it be possible to get a version of your site to test this some more? I wrote unit tests around it and they all pass, so I’m a bit lost why this is happening on your site.

Just send me an email:

I found the issue, thanks to Nico Hoffmann:

When I remove the var_dump($sort); from the core/page.php file, I don’t get the array(0) { } array(0) { } dump anymore :wink:

1 Like

This is embarrassing :slight_smile: Finally fixed though. Sorry for such unnecessary stuff.

1 Like

No problem! Thank you for the great product and quick replies :wink:

Yes, thanks Bastian / Jonathan, Kirby 2.2.2 seems to solve it for me.

1 Like

uninextprev has moved to a new home