I use ArchivistGrouper to sort and list resources by month. Now suddenly whenever I have a resource that is published in March, the whole page goes blank.
After checking the error log, I saw:
/core/components/emo/src/Emo.php : 261) PHP warning: foreach() argument must be of type array|object, bool given
So just for testing I disabled the emo plugin and the page loads again, but with one issue: This is a german site so the month March in german contains an “Umlaut”: März. Interestingly enough the month is now displayed like this: M�rz
I don’t have “Umlaut” issues anywhere else on the site, so I don’t think it’s a database collation issue which was my first thought here.
Also I’m not sure what exactly would have emo caused to interfere with the month here (if that’s even happening).
I can see that the emo plugin fails if M�rz is wrong, but it works if the encoding is fixed.
The problem in the plugin is, that when preg_split on this line fails for some reason,
the plugin returns an empty string.
You could “fix” it by checking the return value $parts and returning the original content if an error occurred.
if ($parts === false){
// An error happened in preg_split. Return the original content.
// Potential email addresses are not obfuscated!!
return $content;
}
But then potential email addresses on the page are not obfuscated.
Another way to fix this, is maybe to try to detect wrong encodings and converting them before preg_split is called.
Interesting… I can basically toggle the page by changing the date of the one resource to either march or anything else…
Anything else I can/should check on my end? Error log still creates the same error as mentioned above.
I think I will just skip on using emo for now. I tried excluding the resource through the selection_range system setting, which did nothing and also putting <!-- emo-exclude --> around my archivistGrouper tag didn’t help.
The built-in output modifier date uses the PHP function strftime as well.
As the function strftime is deprecated (see also this thread), it’s probably a good idea to write a custom output modifier (similar to the one from this thread.)
Thank you for the example! I created the snippet but when I use it as stated in the commented section, I still only get a timestamp as an output: 1615895880.
Sorry, my bad.
I tested it with [[*publishedon]] (that is a formatted string) and not with the pdoResources placeholder [[+publishedon]] (that is a number).
Also, if you use de_DE.UTF-8 for the locale instead of something like de_DE, it should resolve the whole encoding issue (and probably this entire thread).
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.