-
Notifications
You must be signed in to change notification settings - Fork 8
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
PHP less than 7 patch - no null coalescing op #56
base: 7.x
Are you sure you want to change the base?
Conversation
See https://www.php.net/manual/en/migration70.new-features.php Islandora is tested against PHP <7, so we can't use features only available for 7.
An error in the code:
|
My mistake- please check again. |
Still showing errors:
A |
Updated again @bondjimbond |
Still getting a 500 error:
|
I'm not sure what's going on in that line. Is it like an if/else statement all in a single line?
Something like that? |
@@ -22,7 +22,7 @@ function _get_islandora_webform_embargo_settings($nid, $sid = FALSE) { | |||
$single_record = $defaults->execute()->fetchObject(); | |||
} | |||
|
|||
return $single_record ?? FALSE; | |||
isset($single_record) ? return $single_record : return FALSE; |
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 line is strange
maybe?
(Brandon can you test by replacing with this line?)
return $single_record ? $single_record : FALSE;
But i would also initialize $single_record on top, or even return early if not $nid
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.
@DiegoPino That change fixes the Line 25 problem, but we still have a PHP error:
PHP Parse error: syntax error, unexpected '?' in islandora_webform_embargo.module on line 91
The line in question:
'#default_value' => ($defaults && $defaults->embargo_type == 0) ? date_parse($defaults->embargo_date ?? "now") : NULL,
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, same issue, "??", https://www.tutorialspoint.com/php7/php7_coalescing_operator.htm is a PHP 7+ feature. You on older?
needs to be changed by an isset() ?: etc, etc. Simpler to read if you add two lines before, one to check if defaults->embargo_type exists! and one defaults->embargo_type $defaults->embargo_date exits. Then apply the date parse and the other stuff
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.
@bondjimbond FYI, me just lurking here (not sure why i get every existing notification of internet) but not a mantainer.
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.
You're possibly watching this module? :)
Yeah, the purpose of this patch is to make Islandora Webform compatible with PHP versions less than 7. We are currently on 5.6 or something, and Islandora Vagrant is also on on 5.6, so backward-compatible code is needed.
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.
@bondjimbond i get it. Will see if anyone else chimes in here, if not, its just a global ?? find and replace with a isset(). etc. That said, any chance your provider can move you to php 7? 5.6 has been deprecated for 18 months or so already and you will be missing a LOT of features and future modules. Even the patches that can come to Drupal 7 before it dies will be probably for PHP 7+
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.
@bondjimbond I don't have an active PHP 5.x environment to build and test this with either. If you issue a new PR with all the necessary changes I'd be happy to accept it, though.
I'll issue a PR this week to add PHP 5 compatibility back. |
See https://www.php.net/manual/en/migration70.new-features.php
Islandora is tested against PHP <7, so we can't use features only available for 7.
cc @bondjimbond ref #54