Unable to decode output into JSON: Syntax error

Created on 20 February 2024, about 1 year ago
Updated 22 March 2024, about 1 year ago

Problem/Motivation

I don't know why there is in my database a file without filename (maybe because it's an old database). An I don'Ät know either if this case can be usual or it's and edge case, but if the transliteration finds a file without filename it throws an error and the process is stopped.
Anyway the return of the call $file->getFilename(); can be null. It's worth to add an extra validation to avoid this kind of problems.

The error is:

Unable to decode output into JSON: Syntax error

TypeError: Drupal\transliterate_existing_files\TransliterateExistingFiles::sanitizeFilename(): Argument #1 ($filename_with_extension) must be of type string, null given, called in /var/www/html/web/modules/contrib/transliterate  
  _existing_files/src/TransliterateExistingFiles.php on line 78 in Drupal\transliterate_existing_files\TransliterateExistingFiles::sanitizeFilename() (line 181 of /var/www/html/web/modules/contrib/transliterate_existing_files/src  
  /TransliterateExistingFiles.php).   

Steps to reproduce

In the table "files_managed", remove the filename of a file and execute transliteration (with --dry-run works too).

Proposed resolution

Check if we have filename befor calling sanitizeFilename function.

    if (!$filename) {
      return;
    }
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇭Switzerland juagarc4

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024