sunhater / kcfinder

KCFinder web file manager
http://kcfinder.sunhater.com
402 stars 209 forks source link

[PHP 7.2] each() function is deprecated #169

Closed kiwi3685 closed 5 years ago

kiwi3685 commented 6 years ago

Two lines in the file \lib\class_image.php contain the function each() which is deprecated in PHP 7.2

Is this likely to be fixed, or is this project now officially dead?

derUli commented 5 years ago

I use kcfinder in one of my open source projects. If you are still interested in this script I can provide you a version of kcfinder where I fixed your issue and additionally fixed an error where drag and drop a file creates duplicates.

kiwi3685 commented 5 years ago

Thanks. Your version sounds like it will be useful - although as a temporary fix I removed the lines causing the error, with no ill-effect! But a correct fix would be better :-)

derUli commented 5 years ago

Here is a reimplementation of the deprecated each() function

function myEach(&$arr) {
    $key = key($arr);
    $result = ($key === null) ? false : [$key, current($arr), 'key' => $key, 'value' => current($arr)];
    next($arr);
    return $result;
}

Just add this method to kcfinder and replace any calls of each() with myEach(). This will fix the deprecaton warnings.

kiwi3685 commented 5 years ago

Thanks

IVoyt commented 5 years ago

If you are still interested in ... additionally fixed an error where drag and drop a file creates duplicates.

Hi! I am sorry if offtopic. Could you please provide this part of script?

derUli commented 5 years ago

@IVoyt I noticed that my current fix works only if the user don't create a new folder. After the user created a new folder in kcfinder the duplicates error still happens. Are you nevertheless interested in my fix?

derUli commented 5 years ago

If i got the time to look at this, i can fix the other part of the duplicates issue too and provide it as a fork at GitHub.

IVoyt commented 5 years ago

@IVoyt I noticed that my current fix works only if the user don't create a new folder. After the user created a new folder in kcfinder the duplicates error still happens. Are you nevertheless interested in my fix?

If i got the time to look at this, i can fix the other part of the duplicates issue too and provide it as a fork at GitHub.

Yes, that would be great!

derUli commented 5 years ago

@IVoyt here is a link to my quick fixed script. https://github.com/derUli/ulicms/blob/master/ulicms/admin/kcfinder/js/110.dropUpload.js

I currently try to figure out, why the error still happens after creating a new folder.

IVoyt commented 5 years ago

@derUli thanks a lot!

thasneem077 commented 4 years ago

image