Skip to content
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

Filemanager checks empty array 6.4.13 #3706

Open
dorothyDorothy opened this issue Aug 17, 2023 · 2 comments
Open

Filemanager checks empty array 6.4.13 #3706

dorothyDorothy opened this issue Aug 17, 2023 · 2 comments
Assignees
Labels

Comments

@dorothyDorothy
Copy link

I upgraded an add-on which makes use of system/ee/legacy/libraries/Filemanager.php
The call to fetch_upload_dir_prefs() throws an error because the _upload_dir_prefs array has no elements in it.
This is the error:

TypeError Caught
Illegal offset type in isset or empty

The line to check for the empty array is currently:

if (isset($this->_upload_dir_prefs[$dir_id])) {
      return $this->_upload_dir_prefs[$dir_id];
}

I suggest changing this to:

if ((count($this->_upload_dir_prefs) > 0) && (isset($this->_upload_dir_prefs[$dir_id])) ) {
   return $this->_upload_dir_prefs[$dir_id];
}

So that it checks if there are any elements before it starts checking if a particular element exists. This stops an error being thrown.

See line 156 of system/ee/legacy/libraries/Filemanager.php

How To Reproduce
Using Reinos Single Sign On version v5.4.3

Error Messages


TypeError Caught
Illegal offset type in isset or empty

Screenshots / Videos / Template Code

Environment Details:

  • Version: 6.4.13
  • PHP Version 8.2
  • MySQL Version 8.0.34-0ubuntu0.22.04.1 for Linux on x86_64
  • OS: Linux
  • Web Server: Apache

Possible Solution
in system/ee/legacy/libraries/Filemanager.php
public function fetch_upload_dir_prefs($dir_id, $ignore_site_id = false)


if ((count($this->_upload_dir_prefs) > 0) && (isset($this->_upload_dir_prefs[$dir_id])) ) {
return $this->_upload_dir_prefs[$dir_id];
}

Additional context

@intoeetive
Copy link
Contributor

@matthewjohns0n this looks like PHP compatibility issue where _upload_dir_prefs is defined as null vs array

@dorothyDorothy
Copy link
Author

The array wasn't null but it was zero length.

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

No branches or pull requests

3 participants