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

PHP less than 7 patch - no null coalescing op #56

Open
wants to merge 3 commits into
base: 7.x
Choose a base branch
from

Conversation

noahwsmith
Copy link
Member

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

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.
@bondjimbond
Copy link

bondjimbond commented Jul 8, 2020

An error in the code:

PHP Parse error:  syntax error, unexpected ')' in /var/www/drupal/sites/all/modules/islandora_webform/submodules/islandora_webform_embargo/islandora_webform_embargo.module on line 25

@noahwsmith
Copy link
Member Author

My mistake- please check again.

@bondjimbond
Copy link

Still showing errors:

PHP Parse error: syntax error, unexpected '?' in submodules/islandora_webform_embargo/islandora_webform_embargo.module on line 90

A php -l on the file before your commits will reveal these.

@noahwsmith
Copy link
Member Author

Updated again @bondjimbond

@bondjimbond
Copy link

Still getting a 500 error:

PHP Parse error:  syntax error, unexpected 'return' (T_RETURN) in islandora_webform_embargo.module on line 25
Errors parsing islandora_webform_embargo.module

@bondjimbond
Copy link

bondjimbond commented Jul 17, 2020

I'm not sure what's going on in that line. Is it like an if/else statement all in a single line?

  if isset($single_record) {
    return $single_record;
  }
  else {
    return FALSE;
  }

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;
Copy link
Contributor

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

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,

Copy link
Contributor

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

Copy link
Contributor

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.

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.

Copy link
Contributor

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+

Copy link
Member Author

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.

@emudojo
Copy link
Collaborator

emudojo commented Aug 31, 2020

I'll issue a PR this week to add PHP 5 compatibility back.

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.

4 participants