Problem/Motivation

With PHP 8 the first parameter of strncasecmp() can no longer be NULL.

Steps to reproduce

  1. Be running Drupal 7 using PHP 8.0+.
  2. Create a new node that is set unpublish (also works with editing an existing one) and set a value in the scheduler field, and save
  3. The error message Deprecated function: strncasecmp(): Passing null to parameter #1 ($string1) of type string is deprecated in _scheduler_strptime()[...] will occur.

    Proposed resolution

    When initialising $results, set 'meridiem' either to an empty string or 'am', or potentially move the two morning/afternoon check into a conditional block that checks $results['meridiem'] !== NULL

Issue fork scheduler-3336969

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

magicmyth created an issue. See original summary.

jonathan1055’s picture

Status: Active » Needs review

Hi magicmyth,
Thanks for reporting this and for making the MR. I've not used the 7.x-1.x branch with PHP8 so these things have gone unnoticed.

jonathan1055’s picture

Title: Deprecated function: strncasecmp(): Passing null to parameter #1 » Passing null to parameter #1 ($string1) of type string is deprecated

I have now added a branch test for 7.x using php8.1

jonathan1055’s picture

That's good - the new branch test fails with

exception: [Deprecated function] Line 440 of sites/all/modules/scheduler/scheduler.module:
strncasecmp(): Passing null to parameter #1 ($string1) of type string is deprecated

but this is the only failure when running on php8.1

jonathan1055’s picture

Title: Passing null to parameter #1 ($string1) of type string is deprecated » strncasecmp() Passing null to parameter #1 ($string1) of type string is deprecated
Status: Needs review » Fixed

Thanks again for raising this. It's prompted me to add a branch test for php8.1 and this is now the issue testing default too.

jonathan1055’s picture

Title: strncasecmp() Passing null to parameter #1 ($string1) of type string is deprecated » PHP8.1 strncasecmp() Passing null to parameter #1 ($string1) of type string is deprecated
magicmyth’s picture

Thanks for looking into this so fast! Great to have the test in place now. With PHP 7.4 EOL I'll be moving a bunch of sites over to 8.1 soon so that will really help for keeping an eye on things.

jonathan1055’s picture

You're welcome, and thank you for reporting it. It was an oversight that Scheduler 7.x was not being tested at PHP8. I'm pleased that this was the only test failure, as we can see on https://www.drupal.org/pift-ci-job/2579521 which I ran before this commit. Of course, there could be other things which are not compatible with PHP8 and are not covered in the tests. If you find anything, please report it.

Would it help if I released Scheduler 7.x-1.7? It's been more than two years since 7.x-1.6 but there are only a few things that have been committed, see #3171040: Features and Fixes for Scheduler 7.x-1.7 release. But it's probably good to have a new release now that this php8 fix is done.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.