Skip to content

Fix error TypeError: mb_detect_encoding(): Argument #1 ($string) must be of type string, array given in file Lfm.php with change method translateFromUtf8 #1234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deyan-ardi
Copy link

@deyan-ardi deyan-ardi commented May 14, 2024

Summary of the change:

Fix error in windows os for feature File Moving

TypeError: mb_detect_encoding(): Argument #1 ($string) must be of type string, array given in file C:\laragon\www\laravel\glagalinggah-cms\vendor\unisharp\laravel-filemanager\src\Lfm.php on line 237

I replace method translateFromUtf8($input) from

 public function translateFromUtf8($input)
    {
        if ($this->isRunningOnWindows()) {
            $input = iconv('UTF-8', mb_detect_encoding($input), $input);
        }

        return $input;
  }

To

    public function translateFromUtf8($input)
    {
        if ($this->isRunningOnWindows()) {
            if (is_array($input)) {
                foreach ($input as $k => $i) {
                    $rInput[] = iconv('UTF-8', mb_detect_encoding($i), $i);
                }
            } else {
                $rInput = $input;
            }
        } else {
            $rInput = $input;
        }

        return $rInput;
    }

I hove this fix cant be merge, i get error message in my server, thanks

@deyan-ardi deyan-ardi changed the title fix: replace Lfm.php, change method translateFromUtf8 Fix error TypeError: mb_detect_encoding(): Argument #1 ($string) must be of type string, array given in file Lfm.php, change method translateFromUtf8 May 14, 2024
@deyan-ardi deyan-ardi changed the title Fix error TypeError: mb_detect_encoding(): Argument #1 ($string) must be of type string, array given in file Lfm.php, change method translateFromUtf8 Fix error TypeError: mb_detect_encoding(): Argument #1 ($string) must be of type string, array given in file Lfm.php with change method translateFromUtf8 May 14, 2024
@deyan-ardi
Copy link
Author

When this update will be merge?

@patacra
Copy link

patacra commented May 6, 2025

I agree that things seem to take a long time to be merged... and it is quite problematic if we all want to make LFM work a bit better, even so it's a great project.

I also created a pull request and mentioned this one and pull request #1014, which is doing the same almost.

I just saw that both of these pull requests don't correct the function header and also potentially lose the array keys, by rebuilding a new array, which is not necessary, as one can loop over an array and modify it by reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants