behat on php 7.2 vs 7.4

Bug #1964834 reported by Gold
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned
20.10
Fix Released
Medium
Unassigned
21.04
Fix Released
Medium
Unassigned
21.10
Fix Released
Medium
Unassigned
22.04
Fix Released
Medium
Unassigned

Bug Description

In external/composer.json we have behat/mink nailed to a specific version. Moving this version will be time consuming as we quickly enter what I call 'dependency hell'.

There are some elements that do not play well with php 7.4, e.g. implode() is now no longer flexible on the order of its attributes and throws an error.

Edits to the files in external/vendor will be overwritten on the next 'make initcomposer'.

To resolve this I have the following suggestion;

diff --git a/external/composer.json b/external/composer.json
index 2cea1b26cb..384ed0234d 100644
--- a/external/composer.json
+++ b/external/composer.json
@@ -11,12 +11,21 @@
         "guzzlehttp/guzzle": "^6.3.0",
         "phpunit/phpunit": "^8",
         "behat/mink-browserkit-driver": "1.3.3",
- "symfony/css-selector": "3.4.38"
+ "symfony/css-selector": "3.4.38",
+ "cweagans/composer-patches": "^1.7"
     },

     "autoload": {
         "psr-0": {
           "MaharaExtension": "../htdocs/testing/frameworks/behat/extension/"
         }
+ },
+ "config": {
+ "allow-plugins": {
+ "cweagans/composer-patches": true
+ }
+ },
+ "extra": {
+ "patches-file": "composer.patches.json"
     }
 }

This will pull in cweagans/composer-patches, enable it, and set up composer.patches.json as the file that manages our tweaks to the stuff we're checking out.

external/composer.patches.json:
{
  "patches": {
    "behat/mink": {
      "Fix implode()": "escaper.patch"
    }
  }
}

This gives us a single patch file that we will use.

external/escaper.patch:
--- a/vendor/behat/mink/src/Selector/Xpath/Escaper.php 2022-03-15 10:30:18.902551052 +1300
+++ b/vendor/behat/mink/src/Selector/Xpath/Escaper.php 2022-03-15 10:31:41.315406073 +1300
@@ -47,6 +47,6 @@
             }
         }

- return sprintf('concat(%s)', implode($parts, ','));
+ return sprintf('concat(%s)', implode(',', $parts));
     }
 }

This fixes the implode() statement that causes issues on php 7.4.

Changed in mahara:
status: New → Confirmed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "main" branch: https://reviews.mahara.org/12510

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/12510
Committed: https://git.mahara.org/mahara/mahara/commit/b5acfc1f3fa4f733ab55d6bb94d393e669bfe73e
Submitter: Robert Lyon (<email address hidden>)
Branch: main

commit b5acfc1f3fa4f733ab55d6bb94d393e669bfe73e
Author: Gold <email address hidden>
Date: Tue Mar 22 11:23:47 2022 +1300

Bug 1964834: behat on php 7.2 vs 7.4

This enabled patching of composer managed files.

To test:
Check the currect state of the implode() command:
grep implode external/vendor/behat/mink/src/Selector/Xpath/Escaper.php

Run 'make initcomposer'. You should see new output like this:

- Applying patches for behat/mink
escaper.patch (Fix implode())

Run the grep command again and verify the glue is first in the list for
the implode() command.

Change-Id: I192eb8c3ac414738080109e016e0a3a7064a3735
Signed-off-by: Gold <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → Fix Committed
milestone: none → 22.04.0
importance: Undecided → Medium
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "21.10_DEV" branch: https://reviews.mahara.org/12511

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "21.04_DEV" branch: https://reviews.mahara.org/12512

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "20.10_DEV" branch: https://reviews.mahara.org/12513

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/12512
Committed: https://git.mahara.org/mahara/mahara/commit/6518c483b3888ed47616d7f7e59b024315d3e0a3
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.04_DEV

commit 6518c483b3888ed47616d7f7e59b024315d3e0a3
Author: Gold <email address hidden>
Date: Tue Mar 22 11:23:47 2022 +1300

Bug 1964834: behat on php 7.2 vs 7.4

This enabled patching of composer managed files.

To test:
Check the currect state of the implode() command:
grep implode external/vendor/behat/mink/src/Selector/Xpath/Escaper.php

Run 'make initcomposer'. You should see new output like this:

- Applying patches for behat/mink
escaper.patch (Fix implode())

Run the grep command again and verify the glue is first in the list for
the implode() command.

Change-Id: I192eb8c3ac414738080109e016e0a3a7064a3735
Signed-off-by: Gold <email address hidden>
(cherry picked from commit b5acfc1f3fa4f733ab55d6bb94d393e669bfe73e)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/12513
Committed: https://git.mahara.org/mahara/mahara/commit/40b2dd68e6d7e2d2368b19dda5c26dae2340a90a
Submitter: Robert Lyon (<email address hidden>)
Branch: 20.10_DEV

commit 40b2dd68e6d7e2d2368b19dda5c26dae2340a90a
Author: Gold <email address hidden>
Date: Tue Mar 22 11:23:47 2022 +1300

Bug 1964834: behat on php 7.2 vs 7.4

This enabled patching of composer managed files.

To test:
Check the currect state of the implode() command:
grep implode external/vendor/behat/mink/src/Selector/Xpath/Escaper.php

Run 'make initcomposer'. You should see new output like this:

- Applying patches for behat/mink
escaper.patch (Fix implode())

Run the grep command again and verify the glue is first in the list for
the implode() command.

Change-Id: I192eb8c3ac414738080109e016e0a3a7064a3735
Signed-off-by: Gold <email address hidden>
(cherry picked from commit b5acfc1f3fa4f733ab55d6bb94d393e669bfe73e)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/12511
Committed: https://git.mahara.org/mahara/mahara/commit/1ee98acd2deb7e4f0b93c8f19097a2000d847ef8
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.10_DEV

commit 1ee98acd2deb7e4f0b93c8f19097a2000d847ef8
Author: Gold <email address hidden>
Date: Tue Mar 22 11:23:47 2022 +1300

Bug 1964834: behat on php 7.2 vs 7.4

This enabled patching of composer managed files.

To test:
Check the currect state of the implode() command:
grep implode external/vendor/behat/mink/src/Selector/Xpath/Escaper.php

Run 'make initcomposer'. You should see new output like this:

- Applying patches for behat/mink
escaper.patch (Fix implode())

Run the grep command again and verify the glue is first in the list for
the implode() command.

Change-Id: I192eb8c3ac414738080109e016e0a3a7064a3735
Signed-off-by: Gold <email address hidden>
(cherry picked from commit b5acfc1f3fa4f733ab55d6bb94d393e669bfe73e)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.