Error when pulling up docs in Visit History tab

This patch also worked for us, thank you.

After replacing encounters.php with this version we experienced a 500 Internal Server Error - the relevant log entry is reproduced below. The solution was to correct the permissions in the documents directory, as described in issue 26598:

Apache error for Google-ability:

[php:error] [pid 3565:tid 3565] [client 10.6.0.2:33782] PHP Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(/data/www/html/openemr/sites/default/documents/smarty/main/%%1E): Failed to open directory: Permission denied in /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php:76\nStack trace:\n#0 [internal function]: RecursiveDirectoryIterator->__construct()\n#1 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php(76): RecursiveDirectoryIterator->getChildren()\n#2 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_extension_handler.php(133): Smarty_Internal_Method_ClearCompiledTemplate->clearCompiledTemplate()\n#3 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_data.php(270): Smarty_Internal_Extension_Handler->_callExternalMethod()\n#4 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(494): Smarty_Internal_Data->__call()\n#5 /data/www/html/openemr/sites/default/documents/smarty/main/a6ecfa90bb83cc9a6bdd321dfcc14d47b6e46513_0.file.general_view.html.php(6): Smarty_Internal_Template->_decodeProperties()\n#6 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(148): include(‘…’)\n#7 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(105): Smarty_Template_Compiled->process()\n#8 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render()\n#9 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render()\n#10 /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(116): Smarty_Internal_TemplateBase->_execute()\n#11 /data/www/html/openemr/controllers/C_Document.class.php(586): Smarty_Internal_TemplateBase->fetch()\n#12 /data/www/html/openemr/library/classes/Controller.class.php(157): C_Document->view_action()\n#13 /data/www/html/openemr/controller.php(6): Controller->act()\n#14 {main}\n thrown in /data/www/html/openemr/vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php on line 76, referer: https://[siteURL]/openemr/interface/patient_file/history/encounters.php