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

Remove broken call to function_exists in CRM_Utils_String::isUtf8 #22803

Merged

Conversation

braders
Copy link
Contributor

@braders braders commented Feb 20, 2022

Overview

Fix call to function_exists in CRM_Utils_String::isUtf8

Before

In the line if (!function_exists(mb_detect_encoding)), mb_detect_encoding was being treated as a constant - mb_detect_encoding is not a constant, and function_exists expects a string.

After

Valid PHP code.

Comments

Given that this mistake has been unnoticed for a decade I did strongly suspect that the method isUtf8 should be deprecated, and in time removed - it seems unlikely that it is in widespread use.

However, the method is referenced from CRM_Utils_String::isAscii which is in use elsewhere in CiviCRM core. Given this, I was not sure if it was appropriate to deprecate isUtf8 whilst isAscii is still using it...

@civibot
Copy link

civibot bot commented Feb 20, 2022

(Standard links)

@civibot civibot bot added the master label Feb 20, 2022
@demeritcowboy
Copy link
Contributor

I don't remember when but mb was made a system requirement for civi (https://docs.civicrm.org/installation/en/latest/general/requirements/#required-for-civicrm-core), so the function will always exist. I would just remove the if.

@braders braders force-pushed the feature/isutf8-functionexists-fix branch from a408248 to 5d87e89 Compare February 20, 2022 20:34
@braders braders changed the title Fix call to function_exists in CRM_Utils_String::isUtf8 Remove broken call to function_exists in CRM_Utils_String::isUtf8 Feb 20, 2022
@braders
Copy link
Contributor Author

braders commented Feb 20, 2022

I don't remember when but mb was made a system requirement for civi (https://docs.civicrm.org/installation/en/latest/general/requirements/#required-for-civicrm-core), so the function will always exist. I would just remove the if.

That sure does simplify things - changed!

@seamuslee001 seamuslee001 merged commit aef36a0 into civicrm:master Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants