# Undefined offset: 2 Error in /kirby/vendor/getkirby/toolkit/lib/collection.php line 274

**URL:** <https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495>\
**Category:** Questions\
**Tags:** v2\
**Created:** [December 23, 2020, 12:06pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495 "2020-12-23T12:06:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![prestoav](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prestoav](https://forum.getkirby.com/u/prestoav)\
**Post date:** [December 23, 2020, 12:06pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/1 "2020-12-23T12:06:07Z")

</div>

Hi all,

I’m getting an error on the bottom of some pages (after ) as follows:

```
Array
(
    [type] => 8
    [message] => Undefined offset: 2
    [file] => /var/sites/j/jdjcreative.co.uk/public_html/kirby/vendor/getkirby/toolkit/lib/collection.php
    [line] => 274
)

```

I found this post: [Problem with trying to retrieve fields from a User](https://forum.getkirby.com/t/problem-with-trying-to-retrieve-fields-from-a-user/4964)

I’ve since updated Toolkit from GitHub and the issue remains. For info the setup is:

PHP 7.4.6

Kirby:  
Toolkit version: 2.5.14  
Kirby version: 2.5.14  
Panel version: 2.5.14

Any ideas / suggestions gratefully received!

Happy Christmas 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 23, 2020, 12:48pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/2 "2020-12-23T12:48:28Z")

</div>

Could you please post the code that is causing the error?

According to the source code, is must be some related to using filterBy in your template…

---

<div class="post-metadata">

**Author:** ![prestoav](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prestoav](https://forum.getkirby.com/u/prestoav)\
**Post date:** [December 23, 2020, 1:21pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/3 "2020-12-23T13:21:41Z")

</div>

Hi there and thanks for helping out again.

I won’t past the entire code here as it’s quite a long template with a bunch of snippets but I have just been through looking for ‘filter’ and there are no instances of that function in the template or snippets used.

The closest think I can find is use of $pages-\>findByURI within the menu snippet. Might that also be an issue?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 23, 2020, 1:42pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/4 "2020-12-23T13:42:31Z")

</div>

According to the error message, the error is caused in this line in the `$collection->filterBy()` method: [https://github.com/getkirby-v2/kirby/blob/1505b659472480311aa166767c7a3652c3e766fe/vendor/getkirby/toolkit/lib/collection.php#L274](https://github.com/getkirby-v2/kirby/blob/1505b659472480311aa166767c7a3652c3e766fe/vendor/getkirby/toolkit/lib/collection.php#L274)

However, this line shouldn’t really throw an error, because the error control operator `@` is used here.

So what does it mean that this error is shown “at the bottom of the page”? Have you set error handling in your php ini or your scripts or is debugging enabled? Are you using Xdebug with the scream configuration enabled? Or the PECL scream extension?

---

<div class="post-metadata">

**Author:** ![prestoav](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prestoav](https://forum.getkirby.com/u/prestoav)\
**Post date:** [December 23, 2020, 2:16pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/5 "2020-12-23T14:16:50Z")

</div>

Hi again and thanks for your continuing help.

I have made sure error reporting is off in config:

```
// Error Logging
c::set('debug', false);

```

Interesting you should mention error logging as I have noted that the copy on my localhost runs OK. I also know the client has had to ask the hosting company to diagnose a 500 error at the end of last week and it makes me wonder if the hosting company have left error reporting on?

I’ll investigate with them!

---

<div class="post-metadata">

**Author:** ![prestoav](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prestoav](https://forum.getkirby.com/u/prestoav)\
**Post date:** [December 24, 2020, 10:28am UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/6 "2020-12-24T10:28:34Z")

</div>

Hi again and thank you for your help once again!

On investigation this one was nit a Kirby problem but a hosting support problem. The hosting company had been investigating a 500 error a few days previously and had left error reporting on. Thankfully confessed it was their fault when we asked them and all is now solved.

Phew!

thanks again fro you help and happy Christmas everyone 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 24, 2020, 10:29am UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/7 "2020-12-24T10:29:47Z")

</div>

Thanks for reporting back, and happy holidays 🎄.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:22pm UTC](https://forum.getkirby.com/t/undefined-offset-2-error-in-kirby-vendor-getkirby-toolkit-lib-collection-php-line-274/20495/8 "2025-02-06T17:22:42Z")

</div>

Archived on February 6, 2025, 5:22pm UTC


