Consider replacing fnmatch usage

Created on 31 May 2020, about 4 years ago
Updated 13 June 2023, about 1 year ago

Problem/Motivation

The function fnmatch is not available in every PHP build. Related core issue: #2620576: fnmatch() is not available on all environments (i.e QNAP QTS) β†’ .

Running Upgrade Status on Configuration Distribution produces the following:

Proposed resolution

Replace fnmatch() with preg_match().

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada nedjo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA
  • Thank you for these great patches @a.dmitriiev !

    I tested both of these patches out with the config_distro_ignore functionality. In my testing it appears that the patch in #3144145-6: Consider replacing fnmatch usage β†’ has an issue where any ignore rule will match any config name (e.g. foo will match node.type.my_content_type). The original patch in #3144145-2: Consider replacing fnmatch usage β†’ seemed to work in almost all cases but has a minor issue where a partial match now matches a complete config name (e.g. content matches node.type.my_content_type because the generated regex pattern was missing the ^$

    I have updated the patch in #3144145-2: Consider replacing fnmatch usage β†’ to fix the substring issue, use preg_quote, and for coding standards. I have removed the case insensitivity flag because fnmatch() wasn't originally being used with FNM_CASEFOLD. I think in some cases (windows platforms, maybe?) the original implementation using fnmatch() might have been case insensitive in some places and not others.

    Most of the fnmatch() replacements in Drupal have not been a complete reimplementation of the shell-style patterns as regex, but this patch retains the wildcard functionality on * and ?, which I think is useful for the config_distro_ignore use case.

  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

    Patch in #9 looks good to me. Thanks @tadean!

    Discussed this offline with @tadean and we are in agreement that it would be good to merge this ahead of an alpha release with D10 compatibility and create a follow-up issue that adds automated test coverage for this functionality before creating a beta release.

  • πŸ‡ΊπŸ‡ΈUnited States trackleft2

    Tested with many patterns using the test module after changing config within the core.entity_form_display.node.sample_content_type.default.yml file including:

    core.entity_form_display.node.sample_content_type.*
    core.entity_form_display.node.sample_content_typ?.???????
    
  • Status changed to RTBC about 1 year ago
    • tadean β†’ authored 2c4e730d on 2.0.x
      Issue #3144145 by a.dmitriiev, tadean, nedjo, joegraduate, trackleft2:...
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

    Committed to 2.0.x. Thanks all!

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

Production build 0.69.0 2024