# Cache issue with NativeEncoder.php from tedivm

**URL:** <https://forums.concretecms.org/t/cache-issue-with-nativeencoder-php-from-tedivm/6046>\
**Category:** Using Concrete / Help\
**Created:** [August 17, 2023, 1:17pm UTC](https://forums.concretecms.org/t/cache-issue-with-nativeencoder-php-from-tedivm/6046 "2023-08-17T13:17:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![b3rimbau](https://forums.concretecms.org/user_avatar/forums.concretecms.org/b3rimbau/32/3434_2.png) [@b3rimbau](https://forums.concretecms.org/u/b3rimbau)\
**Post date:** [August 17, 2023, 1:17pm UTC](https://forums.concretecms.org/t/cache-issue-with-nativeencoder-php-from-tedivm/6046/1 "2023-08-17T13:17:01Z")

</div>

I’m running Concrete5 5.8.12 on a WIMP stack with PHP 7.4.33.

I’ve been plagued with intermittent (but quite frequent) EMERGENCY exceptions like:

```auto
[2023-08-17 11:59:01] exceptions.EMERGENCY: Exception Occurred: <my_path>\concrete5\concrete\vendor\tedivm\stash\src\Stash\Driver\FileSystem\NativeEncoder.php:25 include(): Failed opening '<my_path>/concrete5/application/files/cache/expensive\0fea6a13c52b4d47\25368f24b045ca84\38a865804f8fdcb6\57cd99682e939275\8f3a01e2e3b200aa\f980d8ea6abd2ae6\aa926918a6c91949\431e2245bd4ce662.php' for inclusion (include_path='<my_path>/concrete5/concrete/vendor;.;C:\php\pear') (2) ["[object] (Whoops\\Exception\\ErrorException(code: 2): include(): Failed opening '<my_path>/concrete5/application/files/cache/expensive\\0fea6a13c52b4d47\\25368f24b045ca84\\38a865804f8fdcb6\\57cd99682e939275\\8f3a01e2e3b200aa\\f980d8ea6abd2ae6\\aa926918a6c91949\\431e2245bd4ce662.php' for inclusion (include_path='<my_path>/concrete5/concrete/vendor;.;C:\\php\\pear') at <my_path\\concrete5\\concrete\\vendor\\tedivm\\stash\\src\\Stash\\Driver\\FileSystem\\NativeEncoder.php:25)"] []

```

which cause the web server to respond with HTTP 500. I’m getting this on two different instances of Concrete5 and on two different Windows servers (2016 and 2022).

The PHP error log shows that most of these are causing a PHP Warning, but eventually they result in a PHP Fatal error. I think this might be leaving cgi/FastCGI processes in a busy and unrecyclable state which then eats up all my CPU and the web server essentially crashes.

I’ve not found much about this topic, but the nearest discussion I found was this:

> <https://github.com/concretecms/concretecms/issues/6268>
>
> The issue is rather critical, visitors will attempt to browse to a page and it'l…l fail and show the error, here is an example from the logs:
> \`\`\`
> Exception Occurred: /var/www/vhosts/\[sitedomainame\]/httpdocs/application/files/cache/0fea6a13c52b4d47/25368f24b045ca84/38a865804f8fdcb6/57cd99682e939275/18e23c785c6a72cf/ca47fbe20fed45aa.php:14 syntax error, unexpected end of file, expecting variable (T\_VARIABLE) or ${ (T\_DOLLAR\_OPEN\_CURLY\_BRACES) or {$ (T\_CURLY\_OPEN) (0) 
> \`\`\`
> 
> This is on a site running community store but appears to be a C5 issue. The Stash library seems to build quite large files and then it seems to struggle reading the whole thing, so I guess that is why we get a syntax error when infact there are none in the cache file.
> 
> Example cache file attached.
> \[ca47fbe20fed45aa.txt\](https://github.com/concrete5/concrete5/files/1604098/ca47fbe20fed45aa.txt)
> 
> A suggestion from the Stash page on github:
> "Try switching to the SQLite backend. The filesystem one works great in testing but runs into various race conditions when put under load."
> 
> Link to Stash issue/conversation: https://github.com/tedious/Stash/issues/374
> 
> So it looks like to use PDO/Sqlite we need to write a new class under:
> \\concrete\\src\\Cache\\Driver\\FileSystemStashDriver.php
> 
> But call it something else like SqliteStashDriver.php and in /concrete/config/ have a choice of drivers maybe:
> \`\`\`
> 'core\_filesystem' =\> \[
> 'class' =\> \\Concrete\\Core\\Cache\\Driver\\FileSystemStashDriver::class,
> //'class' =\> \\Concrete\\Core\\Cache\\Driver\\SqliteStashDriver::class,
> \`\`\`

So - the cache can get into a bit of a pickle with things being read and written simulaneously? The Issue sounds resolved from the point of view of C5 core, but maybe I’ve implemented the cache somewhere and am now running into the issue. Hmm. Any ideas, anyone?

The cache file in question:

```auto
<my_path>/concrete5/application/files/cache/expensive\0fea6a13c52b4d47\25368f24b045ca84\38a865804f8fdcb6\57cd99682e939275\8f3a01e2e3b200aa\f980d8ea6abd2ae6\aa926918a6c91949\431e2245bd4ce662.php

```

exists and the application pool identity as Full Control.

Thanks for reading.  
Chris Peckham

---

<div class="post-metadata">

**Author:** ![b3rimbau](https://forums.concretecms.org/user_avatar/forums.concretecms.org/b3rimbau/32/3434_2.png) [@b3rimbau](https://forums.concretecms.org/u/b3rimbau)\
**Post date:** [August 24, 2023, 11:45am UTC](https://forums.concretecms.org/t/cache-issue-with-nativeencoder-php-from-tedivm/6046/2 "2023-08-24T11:45:19Z")

</div>

This patch has gone some what to improving my situation:

> <https://github.com/tedious/Stash/commit/87d969fa6b01cfccd5c2cf800a9240a62bbbb9a0>

The commit is from Feb 10, 2021

I’ve not managed to reproduce the issue in a vanilla install of ConcreteCMS 8.5.12 but it is inherent in a couple of well-customized instances of the same version, so I suspect my use of the Expensive Cache is highlighting the issue here.

```auto
<my_path>\concrete5\concrete\vendor\tedivm\stash\src\Stash\Driver\FileSystem\NativeEncoder.php:25

```

used to be

```auto
include($path);

```

but the patch changes this to

```auto
try {
    include($path);
} catch (\Error $e) {
    return false;
}

```

The preceding lines test for the existence of this file, so it is surprising that the include can fail, but it does.

---

<div class="post-metadata">

**Author:** ![JohntheFish](https://forums.concretecms.org/user_avatar/forums.concretecms.org/johnthefish/32/3767_2.png) [@JohntheFish](https://forums.concretecms.org/u/JohntheFish)\
**Post date:** [August 24, 2023, 1:25pm UTC](https://forums.concretecms.org/t/cache-issue-with-nativeencoder-php-from-tedivm/6046/3 "2023-08-24T13:25:33Z")

</div>

Does the existence test take into account file system permission to read?

I haven’t encountered the stash issue, but have seen similar where a file is created by a user other than the apache user. Sometimes with composer based installs run from an SSH CLI. Sometimes with FTP.
