Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maltfield
Copy link

Comment on lines +287 to +298
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');
}
Copy link
Member

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?

Copy link
Author

@maltfield maltfield Sep 13, 2024

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?

Copy link
Member

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.

@bsweeney bsweeney linked an issue Sep 13, 2024 that may be closed by this pull request
@bsweeney bsweeney added this to the 3.0.1 milestone Sep 13, 2024
@bsweeney bsweeney modified the milestones: 3.0.1, 3.0.2 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP Fatal error: Call to undefined function ini_set
2 participants