cakephp-error-email icon indicating copy to clipboard operation
cakephp-error-email copied to clipboard

Long error message causes "File name too long" issue

Open smarek opened this issue 5 years ago • 0 comments

[Mon Mar 16 19:12:06.814841 2020] [php7:warn] [pid 23677] [client 1.2.3.4:47120] PHP Warning:  SplFileInfo::openFile(/var/www/html/tmp/cache/error_emails/error_email_error_email_exception_deprecated_exception_request_handler_componentbefore_redirectisdeprecated_thisfunctionalitywillberemovedin400_settheenable_before_redirectoptiontofalsetodisablethiswarningvarwwwhtmlvendorcakephpcakephpsrc_event_event_managerphpline352_youcandisabledeprecationwarningsbysetting_errorerror_levelto_e_a_l_l_e_u_s_e_r_d_e_p_r_e_c_a_t_e_dinyourconfigappphp16384): failed to open stream: File name too long in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 406, referer: https://censored.domain.com/request/path

There is default limit 255 characters on file-name in usual cases, see https://serverfault.com/a/9548/86062

This particular issue can be tested by enabling deprecation warnings, and using 'emailLevels' => ['exception', 'error', 'warning', 'notice', 'strict', 'deprecated'] config

Therefore process generating the throttle cache file should either trim the cache-key to 255 characters (unpractical and problematic), or generate SHA or other hash from cache-key, to stay in file name length limits (sha256 in hex is 64 characters, that should be safe for all situations)

smarek avatar Mar 16 '20 18:03 smarek