Problem/Motivation

Issues with PHP 7.2 compatibility:

  1. Usage of PHP's create_function() function has been deprecated as of PHP 7.2. This is used in plugins/context_reaction_region.inc.
  2. exception: [Warning] Line 455 of sites/all/modules/context/plugins/context_reaction_block.inc:
    count(): Parameter must be an array or an object that implements Countable

Proposed resolution

Replace create_function() with a method.
Test for whether variable is countable before counting. Use approach as used in core in _form_validate().

Remaining tasks

User interface changes

API changes

Data model changes

Comments

bkosborne created an issue. See original summary.

oadaeh’s picture

Assigned: Unassigned » oadaeh

I'm working on this.

oadaeh’s picture

Assigned: oadaeh » Unassigned
Status: Active » Needs review
StatusFileSize
new931 bytes

Attached is a patch that addresses this.

john bickar’s picture

Status: Needs review » Reviewed & tested by the community

I've tested this and it works as advertised. I am able to create new Contexts with region reactions.

herved’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.55 KB

Thanks for this.
There is another warning thrown from context during simpletest runs:

exception: [Warning] Line 455 of sites/all/modules/context/plugins/context_reaction_block.inc:
count(): Parameter must be an array or an object that implements Countable

Maybe we can include it in this issue? If not let me know I'll create a new one.

The other issues are from D7 core which are covered in core issues.

Status: Needs review » Needs work

The last submitted patch, 5: context-support_php_72-2946595-5.patch, failed testing. View results

herved’s picture

No idea what's going on with the testbot...

vinmassaro’s picture

Status: Needs work » Reviewed & tested by the community

Patch applies cleanly to 7.x-3.x-dev and works well, thanks! Moving to needs review.

vinmassaro’s picture

Status: Reviewed & tested by the community » Needs review
nedjo’s picture

Status: Needs review » Needs work
+++ b/plugins/context_reaction_block.inc
@@ -450,12 +450,8 @@ class context_reaction_block extends context_reaction {
+    return round((count($blocks) + 2) / 2);

This line is not equivalent to the removed code. It counts the regions. The removed code counts the blocks in any region.

nedjo’s picture

Title: Remove usage of deprecated create_function() calls for PHP 7.2+ future proofing » Address PHP 7.2+ compatibility issues
Status: Needs work » Needs review
StatusFileSize
new1.63 KB
nedjo’s picture

Issue summary: View changes

Updating summary with details of issues and fixes.

nedjo’s picture

Issue summary: View changes
nedjo’s picture

StatusFileSize
new1.62 KB
new609 bytes

  • nedjo committed cedb5eb on 7.x-3.x authored by oadaeh
    Issue #2946595 by nedjo, oadaeh: Address PHP 7.2+ compatibility issues
    
nedjo’s picture

Status: Needs review » Fixed

Applied.

Status: Fixed » Closed (fixed)

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

liam morland’s picture

Is there a reason this wasn't done with an anonymous function instead of creating collapseRegion()?