Recent Topics

Short link's plugin is not saving its configuration correctly

Started by on Mar 13, 2018 – Contents updated: Mar 23, 2018

Mar 13, 2018 20:36    

Steps to reproduce:

  1. On the demo site go to the plugins settings page for any blog:
    http://demo2.b2evolution.net/stable/admin.php?ctrl=coll_settings&tab=plugins&action=edit&blog=1
  2. Expand Short Links.
  3. See several of the checkboxes have been checked.
  4. Click "Save Changes!"
  5. Expand Short Links.
  6. All the checkboxes are unchecked

Trying to update any of the boxes results in all the boxes being unchecked.
I'm also seeing this behaviour on my 6.9.7-stable version.

(where's the preview button gone, not sure my markdown is all correct!)

Mar 14, 2018 23:39

I've been looking at this issue and think I have found the cause of the problem.
The /plugins/shortlinks_plugin/_shortlinks.plugin.php page stores its plugin settings using a checklist type.

This looks like a half-implemented feature! Reading the checklist type from the database expects a PHP serialised key-value array. Saving the checklist type resets the array of new options to null, in CollectionSettings->set( $col_key1, $col_key2, $value ) because it passes the checklist array to utf8_substr() which returns null. So "" is saved to the database for plugin<id>_link_types. Once "" is saved into the database there is no object to de-serialise and so all the options are blank. It looks like it works at the beginning because there is no corresponding link_types record in the databases and the defaults are used.

There are 2 ways to fix this:

  1. Replace the checklist type with a number of checkbox types (same solution as the markdown plugin and all the others).
    2) In file /inc/plugins/_plugin.funcs.php:


    if( isset($parmeta['type']) && strpos( $parmeta['type'], 'array' ) === 0 )
    { // make keys (__key__) in arrays unique and remove them
        handle_array_keys_in_plugin_settings($l_value);
    }

        // --------------- XXX catch special case for checklist ---------------
    if( isset($parmeta['type']) && strpos( $parmeta['type'], 'checklist' ) === 0 )
    { // serialize array:
        $l_value = serialize($l_value);
    }

    if( isset( $parmeta['type'] ) && $parmeta['type'] == 'integer' )
    {    // Convert to correct integer value:

This converts the array into a serialised string so that it can be safely saved as normal. It feels a bit like a hack so maybe you can think of a better place to put the code that prepares the checklist data type for saving.

This post has 5 feedbacks awaiting moderation...


Form is loading...

blog software – This forum is powered by b2evolution CMS, a complete engine for your website.