# Archivist 500 error

**URL:** <https://community.modx.com/t/archivist-500-error/1672>\
**Category:** Extras\
**Created:** [October 16, 2019, 2:14pm UTC](https://community.modx.com/t/archivist-500-error/1672 "2019-10-16T14:14:23Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 16, 2019, 2:14pm UTC](https://community.modx.com/t/archivist-500-error/1672/1 "2019-10-16T14:14:23Z")

</div>

Hi All!

I have a blog which i created using collections/tagger/archivist.  
It has been up and running for many years, and not a problem, but today a user mentioned that the archives section isn’t working, and throws 500 errors whenever they click on a year.

I haven[t’ changed anything, so all i can think is that an update somewhere down the line killed it.

This is what I have to create the links to the years:

```
` [[!Archivist? &target=`135` &parents=`137` &useMonth=`0` &tpl=`archiveLinkCollectionsTpl`]]

```

`  
The target resource (135) contains this:

```
   ` [[!getPage?
      &element=`getArchives`
      &elementClass=`modSnippet`
      &tpl=`BlogCollectionsRowTpl`
      &hideContainers=`1`
      &pageVarKey=`page`
      &parents=`137`
      &includeTVs=`1`
      &toPlaceholder=`archives`
      &limit=`5`
      &cache=`0`
      &showHidden=`1`
    ]]

```

[[!+archives]]`

But when a user clicks on the year of 2019 for example, it goes to:

[site.com/archives/2019/](http://site.com/archives/2019/) and throws a 500 error.

Any ideas what could be causing this?  
I’ve reviewed my code in the docs and cannot see any issues.

Thanks in advance!  
Andy

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 16, 2019, 2:19pm UTC](https://community.modx.com/t/archivist-500-error/1672/2 "2019-10-16T14:19:15Z")

</div>

**UPDATE** : I just worked out that it’s the PHP version which is causing the problem!  
I recently updated the site to run on PHP7.2.  
I just changed it back to PHP7.0 =, and the archives work.

Any ideas why?  
Or more importantly how to fix it?

Thanks!  
Andy

---

<div class="post-metadata">

**Author:** ![digitalpenguin](https://community.modx.com/user_avatar/community.modx.com/digitalpenguin/32/32_2.png) [@digitalpenguin](https://community.modx.com/u/digitalpenguin)\
**Post date:** [October 16, 2019, 2:44pm UTC](https://community.modx.com/t/archivist-500-error/1672/3 "2019-10-16T14:44:50Z")

</div>

Are you getting any errors in the MODX log?

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 16, 2019, 2:51pm UTC](https://community.modx.com/t/archivist-500-error/1672/4 "2019-10-16T14:51:48Z")

</div>

Thanks - just checked and it says this:  
`[2019-10-16 14:51:25] (ERROR @ /home/site/public_html/core/cache/includes/elements/modsnippet/67.include.cache.php : 142) PHP warning: count(): Parameter must be an array or an object that implements Countable `

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [October 16, 2019, 3:22pm UTC](https://community.modx.com/t/archivist-500-error/1672/5 "2019-10-16T15:22:45Z")

</div>

At this line:

> <https://github.com/modxcms/Archivist/blob/3dd3bf289881b2bc62ad9e976e14c277732baa40/core/components/archivist/elements/snippets/snippet.archivist.php#L137>

you could try to add:

```auto
if (!$resources){
    return '';
}

```

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 16, 2019, 3:59pm UTC](https://community.modx.com/t/archivist-500-error/1672/6 "2019-10-16T15:59:09Z")

</div>

> [@bruno17](#):
>
> if (!$resources){ return ‘’; }

Thanks Bruno - but unfortunately that didn’t work. ☹

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [October 16, 2019, 4:27pm UTC](https://community.modx.com/t/archivist-500-error/1672/7 "2019-10-16T16:27:14Z")

</div>

might be an MODX - issue then and the object returned by getIterator doesn’t implement Countable.

did you try, just to set the debug - system-setting to 0?

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 17, 2019, 9:13am UTC](https://community.modx.com/t/archivist-500-error/1672/8 "2019-10-17T09:13:39Z")

</div>

OK thanks Bruno - I hadn’t tried that - the setting was blank, but I just added a zero in there - and no change unfortunately. ☹

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 17, 2019, 10:43am UTC](https://community.modx.com/t/archivist-500-error/1672/9 "2019-10-17T10:43:04Z")

</div>

I just found this in the Archivist Bug reporting, which sounds like the same problem as mine:

> <https://github.com/modxcms/Archivist/issues/15>
>
> Line 142: $count = count($resources);
> 
> Seems to not be getting the object that… it is supposed to be getting. I yields this error:
> 
> count(): parameter must be an array or an object that implements countable
> 
> It seems that the issue appears when using PHP 7.2
> 
> We are using MODX 7.0 and PHP Version 7.2.19

---

<div class="post-metadata">

**Author:** ![digitalpenguin](https://community.modx.com/user_avatar/community.modx.com/digitalpenguin/32/32_2.png) [@digitalpenguin](https://community.modx.com/u/digitalpenguin)\
**Post date:** [October 18, 2019, 3:25am UTC](https://community.modx.com/t/archivist-500-error/1672/10 "2019-10-18T03:25:57Z")

</div>

After making the code change Bruno suggested, did the error message change? Or still the same one?

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 18, 2019, 8:34am UTC](https://community.modx.com/t/archivist-500-error/1672/11 "2019-10-18T08:34:56Z")

</div>

Hmm - strangely there is no error in the logs with that added code - but I still get a 500 error for the archive pages e.g.:  
[https://www.site.co.uk/archives/2019](https://www.site.co.uk/archives/2019)

---

<div class="post-metadata">

**Author:** ![bobray](https://community.modx.com/user_avatar/community.modx.com/bobray/32/46_2.png) [@bobray](https://community.modx.com/u/bobray)\
**Post date:** [October 19, 2019, 5:08am UTC](https://community.modx.com/t/archivist-500-error/1672/12 "2019-10-19T05:08:25Z")

</div>

Most likely something [here](https://www.php.net/manual/en/migration72.incompatible.php), though it may be very difficult to find.

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 21, 2019, 10:06am UTC](https://community.modx.com/t/archivist-500-error/1672/13 "2019-10-21T10:06:46Z")

</div>

Thank Bob

That’s all a bit beyond my knowledge base I’m afraid.  
Fingers crossed the developer comes back with an upgrade/fix because I’ve had to upgrade php to 7.2 due to other extras making it a minimum requirement.

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 23, 2019, 11:47am UTC](https://community.modx.com/t/archivist-500-error/1672/14 "2019-10-23T11:47:00Z")

</div>

Hi all. I have another site which runs a blog using Articles.

This still uses archivist to create the archive pages - but that works fine, and it’s on php 7.2. and MODX 2.7.2. So I suppose a work around is to recreate the blog using Articles, instead of getResources/Collections. I just cannot work out why it would be different, as they both use the same Extra (Archives).

---

<div class="post-metadata">

**Author:** ![Lachlan1241](https://community.modx.com/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@Lachlan1241](https://community.modx.com/u/Lachlan1241)\
**Post date:** [October 24, 2019, 12:05pm UTC](https://community.modx.com/t/archivist-500-error/1672/15 "2019-10-24T12:05:21Z")

</div>

The .htaccess file is the most common cause of 500 errors. There’s one in the root and sometimes one in the Manager folder. Have you changed either one lately?

Do you have the latest version of MODX?

It sounds like you’ve eliminated most of the possible causes on your end, at that point, it’s most likely something your host did, like a PHP upgrade, change in the file structure, new php.ini, or new mod\_security rules. It’s also possible that the database is overloaded and is timing out or rejecting calls from [the](https://www.dgcustomerfirst.review/) Manager.

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 29, 2019, 11:07am UTC](https://community.modx.com/t/archivist-500-error/1672/16 "2019-10-29T11:07:51Z")

</div>

Hi. The htaccess file haven’t changed. All other pages work fine - it’s just the archives. I’m running the latest version of MODX.

~The problem is definitely linked to the PHP version - which I upgraded. It works on php V7, but not PHP v7.2,

---

<div class="post-metadata">

**Author:** ![joshualuckers](https://community.modx.com/user_avatar/community.modx.com/joshualuckers/32/4244_2.png) [@joshualuckers](https://community.modx.com/u/joshualuckers)\
**Post date:** [October 29, 2019, 3:23pm UTC](https://community.modx.com/t/archivist-500-error/1672/17 "2019-10-29T15:23:38Z")

</div>

Does it help replacing `count` by `iterator_count` on this line?

> <https://github.com/modxcms/Archivist/blob/433caf464abb3aa1e83e463154116f0ba3be2e9b/core/components/archivist/elements/snippets/snippet.archivist.php#L142>

---

<div class="post-metadata">

**Author:** ![tm2000](https://community.modx.com/user_avatar/community.modx.com/tm2000/32/178_2.png) [@tm2000](https://community.modx.com/u/tm2000)\
**Post date:** [October 29, 2019, 4:02pm UTC](https://community.modx.com/t/archivist-500-error/1672/18 "2019-10-29T16:02:42Z")

</div>

Thanks for this - but I just managed to solve it - from a previous post i just found:

> [@Archivist Landing Page Blank](https://community.modx.com/t/archivist-landing-page-blank/1420):
>
> Having updated to PHP 7.2, Archivist now loads a blank page from the [[+url]] in the navigation link Tpl chunk called by [[!Archivist?]] , so for example, the archive link to [www.url.com/archive-result/2018/08](http://www.url.com/archive-result/2018/08) shows a blank page, with a ‘HTTP ERROR 500’ The error log shows /home/p/public\_html/core/cache/includes/elements/modsnippet/1.include.cache.php : 142) PHP warning: count(): Parameter must be an array or an object that implements Countable We see this stack trace: mod\_fcgid: stderr: #0 …

Basically on line 60 of the snippet getArchives it says to change:

```
$where[] = 'FROM_UNIXTIME(`'.$filterField.'`,"%Y") = "'.$year.'"';

```

to:

```
$where =[];
$where[] = 'FROM_UNIXTIME(`'.$filterField.'`,"%Y") = "'.$year.'"';

```

All working fine now!  
Only problem is if there is a future update of the snippet, it may reverse the fix if it’s not in the update?

Thanks all - Got there in the end!!

---

<div class="post-metadata">

**Author:** ![system](https://community.modx.com/user_avatar/community.modx.com/system/32/2_2.png) [@system](https://community.modx.com/u/system)\
**Post date:** [October 31, 2019, 4:02pm UTC](https://community.modx.com/t/archivist-500-error/1672/19 "2019-10-31T16:02:44Z")

</div>

Closed on October 31, 2019, 4:02pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
