GLOB_BRACE is not supported on Alpine based Linux distributions

Created on 29 April 2024, 7 months ago
Updated 5 July 2024, 4 months ago

Problem/Motivation

Steps to reproduce

Run Media library importer on a Docker container based on Alpine

Proposed resolution

Replace GLOB_BRACE usage with the following.

1. Add this method to the class.

 function getMediaFiles($media_folder, $media_extensions) {
    // Split the extensions into an array
    $extensions = explode(',', $media_extensions);

    // Initialize an array to hold the results
    $media_files = [];

    // Loop through each extension and merge the results
    foreach ($extensions as $extension) {
        $media_files = array_merge($media_files, glob("$media_folder/*.$extension"));
    }

    return $media_files;
  }

2. Replace the usages of GLOB_BRACE

        // $media_files = glob("$media_folder/*.{" . $media_extensions . "}", GLOB_BRACE);

must be replaced with

        $media_files = $this->getMediaFiles($media_folder, $media_extensions);

on both places within MediaLibraryImporterService.php, rename arguments as needed.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024