-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check if ini_set is available to prevent Fatal Errors #3524
base: master
Are you sure you want to change the base?
Conversation
maltfield
commented
Sep 13, 2024
- PHP Fatal error: Call to undefined function ini_set #3523
if (function_exists('ini_get') && function_exists('ini_set')) { | ||
if (sprintf('%.1f', 1.0) !== '1.0') { | ||
$this->systemLocale = setlocale(LC_NUMERIC, "0"); | ||
setlocale(LC_NUMERIC, "C"); | ||
} | ||
|
||
$this->pcreJit = @ini_get('pcre.jit'); | ||
@ini_set('pcre.jit', '0'); | ||
$this->pcreJit = @ini_get('pcre.jit'); | ||
@ini_set('pcre.jit', '0'); | ||
|
||
$this->mbstringEncoding = mb_internal_encoding(); | ||
mb_internal_encoding('UTF-8'); | ||
$this->mbstringEncoding = mb_internal_encoding(); | ||
mb_internal_encoding('UTF-8'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you wrap this whole block in the condition instead of just the lines using ini_get
/ini_set
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I assumed that was the best way to do this with the fewest number of lines changed. I can add a few more conditionals so that only the 1-line ini_set
and ini_get
calls are wrapped, if others think that's better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preference would be to change only the relevant lines. You're also disabling changes to locale and internal encoding, both of which can completely break rendering if configured in a way that's incompatible with Dompdf.