Support » Plugin: WordPress Media Library Folders » Warning appearing on Subscribers

  • Resolved runar.orested

    (@runarorested)


    When Media Library Plus is installed an active in a WP website, and you are logged in as a subscriber, this error notice appears, both on the public side and in the Administration panel:

    Notice: Undefined index: upload_files in /home/[InstallationDependant]/wp-content/plugins/media-library-plus/maxgalleria-media-library.php on line 5138

    This warning appears only for logged-in users that cannot view/interact/upload files to the media library, in other words, subscribers. Roles above subscriber, or unlogged user do not show this warning.

    Yes, I know that warnings can be disabled by PHP configuration, but because some other components are being tweaked and developed on the fly, I prefer to have them enabled.

    I noticed it after updating WP to 5.0. You can test it on http://www.bredaformacion.com with the user “testsubscriber” and password “dukey”. Site and plugins are up to date (April 4th).

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author AlanP57

    (@alanp57)

    Ok, I have log in information. If you would like to edit your post and remove it, place do so.

    Plugin Author AlanP57

    (@alanp57)

    I see the notice, but I am not a able to reproduce this issue. The plugin does check for the existence of the ‘upload_files’ property in version 4.3.9 of the plugin. If you would like to send me the information about your site’s configuration, you can go to the Support sub menu item, the System Information tab; copy the site information and paste it into an email and send it to alan@maxfoundry.com.

    Plugin Author AlanP57

    (@alanp57)

    Thank you for sending the system information. I don’t know if this issue is caused by a different PHP version. I am using 7.1.12.

    I’ve tried with only “Media Library Folders” enabled and it still does appears, so does not seem a plugin interaction. Unfortunately I can’t rollback WordPress to 4.9, and the host of this blog does not allow to manage Apache itself.

    After tinkering a bit, I’ve fixed it myself replacing the function with this one:

    public function get_upload_status() {
    $data = get_userdata(get_current_user_id());
    // This reverses the polarity of the neutron flow…
    if (!is_object($data) or !isset($data->allcaps[‘upload_files’]))
    $this->current_user_can_upload = false;
    else
    $this->current_user_can_upload = $data->allcaps[‘upload_files’];
    }

    This one returns false if the upload_files cap is unlisted in the Wp_User object, as it it should be the case in case of subscribers, which only are allowed to retrieve data and modify their own profile.

    Probably a proper fix should be be something like:

    public function get_upload_status() {
    $data = get_userdata(get_current_user_id());

    // Activating the sonic screwdriver…
    if (is_object($data))
    $this->current_user_can_upload = $data-has_cap(‘upload_files’);
    else
    $this->current_user_can_upload = false;
    }

    Please confirm the fix is correct and does not screw up something else.

    • This reply was modified 5 months, 3 weeks ago by  runar.orested.
    Plugin Author AlanP57

    (@alanp57)

    This seems to be a perfect solution. I’ll include it in the next release of the plugin.

    Thank you, i’ll delete the test user now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.