-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
[REF][PHP8.1] Fix a couple of deprecations in php8.1 by specifying th… #23851
Conversation
(Standard links)
|
CRM/Utils/SQL/BaseParamQuery.php
Outdated
@@ -184,6 +184,7 @@ public function param($keys, $value = NULL) { | |||
* | |||
* @return bool | |||
*/ | |||
#[ReturnTypeWillChange] |
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.
that is super interesting - it does feel like this particular one should be reliably a bool though?
@@ -202,6 +203,7 @@ public function offsetExists($offset) { | |||
* @see param() | |||
* @see ArrayAccess::offsetGet | |||
*/ | |||
#[ReturnTypeWillChange] |
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.
does changing * @return mixed
to * @return null|int
make this unnecessary?
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.
so i think what it wants is a function hint of :mixed
but that has different connotations in php7.x to php8.x
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.
Yeah I don't think there's any other way to do this to support both php 7 and 8, since mixed doesn't exist in php 7 (it thinks it's a class type and so then wants an instance of class mixed
).
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.
One thing to think about, but maybe there's no way around it, is that it won't be possible to support both php 7 and 9 at the same time, because php 9 will ignore these #[ReturnTypeWillChange]
and require a return type specified, but php 7 won't let you specify mixed. One possibility, but is a lot of work, is to refactor all these mixed functions to not be so vague. But I don't think civi will be the only project in that boat, so hopefully php 9 will be far enough out that civi will be able to stop supporting php 7 by then. It just might cause difficulty while trying to prep for php 9.
f057d6c
to
9f34af4
Compare
CRM/Core/I18n.php
Outdated
@@ -801,7 +801,7 @@ function ts($text, $params = []) { | |||
if ($bootstrapReady) { | |||
// just got ready: determine whether there is a working custom translation function | |||
$config = CRM_Core_Config::singleton(); | |||
if (isset($config->customTranslateFunction) and function_exists($config->customTranslateFunction)) { | |||
if (isset($config->customTranslateFunction) && !CRM_Utils_System::isNull($config->customTranslateFunction) && function_exists($config->customTranslateFunction)) { |
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.
I suppose the function name could be 0
, but since that's unlikely could this just be if (!empty($config->customTranslateFunction) && function_exists($config->customTranslateFunction)) {
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.
ok have updated to that @demeritcowboy
9f34af4
to
f605270
Compare
CRM/Core/I18n.php
Outdated
@@ -801,7 +801,7 @@ function ts($text, $params = []) { | |||
if ($bootstrapReady) { | |||
// just got ready: determine whether there is a working custom translation function | |||
$config = CRM_Core_Config::singleton(); | |||
if (isset($config->customTranslateFunction) and function_exists($config->customTranslateFunction)) { | |||
if (isset($config->customTranslateFunction) && !empty($config->customTranslateFunction) && function_exists($config->customTranslateFunction)) { |
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.
Oh I meant the whole thing would just be if (!empty($config->customTranslateFunction) && function_exists($config->customTranslateFunction)) {
since there's no need to check isset if checking empty, but ok.
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.
ok updated to that now @demeritcowboy
…at return type may change in BaseParamQuery and by ensuring that we don't pass null into function_exists in I18n class Replace some ReturnTypeWillChange with later return types as they should be backward compatible Dave D Fix Completely switch to just not empty on the customTranslationFunction check
f605270
to
fc651f9
Compare
…at return type may change in BaseParamQuery and by ensuring that we don't pass null into function_exists in I18n class
Overview
This fixes 2 deprecations in php8.1
Deprecated: function_exists(): Passing null to parameter #1 ($function) of type string is deprecated in /home/jenkins/bknix-edge/build/build-1/web/sites/all/modules/civicrm/CRM/Core/I18n.php on line 804
Before
Notices shown during boot to run tests
After
Less notices
ping @totten @eileenmcnaughton @demeritcowboy