• Resolved qaws

    (@qaws)


    Hi, I’ve just upgraded to v2.4.9 and I now get HTTP 500 errors for the upload.php page (i.e. the Media Library). If I deactivate the Admin Columns, the Media Library loads correctly.

    I had previously had extra admin columns on the “Media Library Assistant” page (/wp-admin/upload.php?page=mla-menu), which has been working fine for the past 4 weeks since I installed Admin Columns originally.

    My setup is:
    I create extra fields using “Advanced Custom Fields”, added them to the Media Library, and display them on the “Media Library Assistant” page using Admin Columns.

    upload.php now returns a HTTP 500 error if I try to access, under the Media menu, either “Library”, “WP Smush” or “Assistant”, since these all load the upload.php page.

    https://www.ads-software.com/plugins/codepress-admin-columns/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The Admin Columns 2.4.9 update makes changes (not included in the Change Log) that break Media Library Assistant and other plugins that extend the CPAC_Storage_Model.

    A new method, init_manage_columns() has been added but no default has been supplied. This causes a fatal error when Admin Columns calls the non-existent method.

    Another method’s name has been changed. The old is_columns_screen() has become is_current_screen(). Any plugin that extends is_columns_screen() will fail until it implements the new method (and retains the old method for people who use older Admin Columns versions).

    A bug has been introduced in the CPAC::get_current_storage_model() method. Before 2.4.9 this method returned as soon as $storage_model->is_current_screen() returned true. Now it runs through the entire array of storage models and returns the LAST model that returned true. This means that plugins using the page= parameter to extend a WordPress screen are ignored.

    I have uploaded a new MLA Development Version dated 20160122 that corrects the fatal errors. To get the Development Version, follow the instructions in this earlier topic:

    Shortcode not working in (special) widget

    It would be great if you can install the MLA Development Version and let me know if it works for you. Of course, if any other problems emerge I want to know about them as well.

    Regarding my earlier comment:

    A bug has been introduced in the CPAC::get_current_storage_model() method. Before 2.4.9 this method returned as soon as $storage_model->is_current_screen() returned true. Now it runs through the entire array of storage models and returns the LAST model that returned true. This means that plugins using the page= parameter to extend a WordPress screen are ignored.

    Further investigation and thought reveals that MLA worked with the earlier version of CPAC::get_current_storage_model() because MLA manipulated the $storage_models array to ensure that MLA’s submenu came before the WordPress CPAC_Storage_Model_Media model. I can change MLA to find the current Admin Columns version and do a version-dependent manipulation, but it would be better if Admin Columns had a stable, accurate way of handling submenu items added with the WordPress add_submenu_page() function. That function takes both a $parent_slug and a $menu_slug parameter. The CPAC_Storage_Model::is_current_screen() method could use both to determine the true current screen.

    Thread Starter qaws

    (@qaws)

    Hi David, sorry I didn’t test this, my e-mail notification from this post went astray.

    I’ve upgraded to v2.23 of Media Library Assistant and I can confirm the fixes you added into this have worked. Thanks for the help!

    It sounds like there’s also some recoding to be done by the Admins Column team based on your suggestions.

    Plugin Author Stefan van den Dungen Gronovius

    (@dungengronovius)

    I’ve create a ticket for the get_current_storage_model bug. We’ve changed it back to return the first storage_modal where is_current_screen is true instead of running through the entire array. This will be in a next release.

    We also learned to make good use of the WordPress deprecated functions instead of just replacing functions with new ones :). We were not aware that there are other plugin that are using our storage_models.

    Thanks for your response and for your consideration of the issues I raised.

    I have already released a new version of MLA (v2.24) that accommodates the change you made in Admin Columns 2.4.9. If you change things back you will break my code and the “current screen bug” will return. Here’s my current code:

    /**
     * Define the Media/Assistant submenu screen to the Admin Columns plugin
     *
     * @since 2.22
     *
     * @param    array    $storage_models List of storage model class instances ( [key] => [CPAC_Storage_Model object] )
     * @param    object    $cpac CPAC, the root CodePress Admin Columns object
     */
    public static function admin_columns_support( $storage_models, $cpac ) {
        require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-support.php' );
        MLACore::$admin_columns_storage_model = new CPAC_Storage_Model_MLA();
        /*
         * Put MLA before/after WP Media Library so is_columns_screen() will work
         */
        $new_models = array();
        foreach ( $storage_models as $key => $model ) {
            if ( 'wp-media' == $key ) {
                if ( version_compare( CPAC_VERSION, '2.4.9', '>=' ) ) {
                    $new_models[ $key ] = $model;
                    $new_models[  MLACore::$admin_columns_storage_model->key ] = MLACore::$admin_columns_storage_model;
                } else {
                    $new_models[  MLACore::$admin_columns_storage_model->key ] = MLACore::$admin_columns_storage_model;
                    $new_models[ $key ] = $model;
                }
            } else {
                $new_models[ $key ] = $model;
            }
        }
    
        /*
         * If we didn't find wp-media, add our entry to the end
         */
        if ( count( $storage_models ) == count( $new_models ) ) {
            $new_models[ $storage_model->key ] = MLACore::$admin_columns_storage_model;
        }
    
        return $new_models;
    }

    It would be much better for my plugin if you left your v2.4.9 code in place until you work out a comprehensive way to accommodate submenu items added with the WordPress add_submenu_page() function.

    Your plan to “good use of the WordPress deprecated functions” will address the is_columns_screen() has become is_current_screen() issue, but the root cause of the HTTP 500 Errors was the addition of the new init_manage_columns() functions without a default implementation in the base class. That’s a separate issue.

    I added Admin Columns support to MLA by following the instructions you gave me in this earlier topic on your support forum:

    Making Admin Columns available in Media Library Assistant

    In that topic you posted a link to:

    Extendable for WP_list_tables?

    which gave me the information I needed. I wouldn’t be surprised if others have found the information and added support as well.

    Thanks again for your response. Please let me know if you are changing your get_current_storage_model back to the v2.4.9 implementation; it will save me from doing another emergency MLA release.

    Plugin Author Stefan van den Dungen Gronovius

    (@dungengronovius)

    Hi David,

    Can you please contact me on our admincolumns.com e-mailadres? If you like I can send you the beta release of our upcoming release to see if it works with the current version of your plugin. I’ve downloaded the the 2.24 version of your plugin and it seems to work with the chances we already made.

    Thanks for your update and your offer. I went to your web site and sent a message through the “Chat offline – email us” form. If that doesn’t reach you, send me your contact information here:

    Fair Trade Judaica/Contact Us

    If you have trouble accessing the FTJ site, post a note here with your country of origin and I can temporarily unblock it.

    You wrote “I’ve downloaded the the 2.24 version of your plugin and it seems to work with the chances we already made.” That’s great. Just to confirm, the problem caused by the get_current_storage_model changes is subtle. On the Media/Assistant submenu screen, the “Edit columns” button links to /wp-admin/options-general.php?page=codepress-admin-columns&cpac_key=wp-media with the bug, and it should link to /wp-admin/options-general.php?page=codepress-admin-columns&cpac_key=mla-media-assistant only the cpac_key= argument is different.

    I welcome the chance to try your beta release. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New HTTP 500 errors for Media Library’ is closed to new replies.