Greetings,

While doing refactoring for our Drupal project we found a few things in Superfish that we want to help you with. I will be sending a few feature requests. Every my request is tested by me.

The first one is a code optimization.

1. I suggest to move: superfish_block_configure(), superfish_block_save(), superfish_form_block_admin_configure_alter() and superfish_block_validate() into superfish.admin.inc since this code is not needed on 99% of site pages. During site life cycle block configuration is almost never changed, so no need to load it in memory on each page load.
To have it working you need to implement this event in superfish.module:

/**
 * Implements hook_hook_info().
 */
function superfish_hook_info() {
  $hooks = array(
    'block_configure' => array(
      'group' => 'admin',
    ),
    'block_save' => array(
      'group' => 'admin',
    ),
    'form_block_admin_configure_alter' => array(
      'group' => 'admin',
    ),
  );
  return $hooks;
}

This change reduce the sise of superfish.module almost twice!

2. There is no need to check required fields for empty values on your own validation function. You can use '#required' => TRUE instead when building a form. This is a standard validation. All other checks are fine.

3. And a small one... no need to do explicit return in superfish_block_save().

Please find two patches attached to this issue.

Thank you for your work on this module and hope to participate in its development and support since our company is interested in using this module on all future sites!

CommentFileSizeAuthor
superfish.admin_.inc_.patch27.68 KBardas
superfish.module.patch28.64 KBardas

Comments

neochief’s picture

Status: Active » Reviewed & tested by the community

Looks good for me.

andypost’s picture

Version: 7.x-1.9-beta4 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

patch should live in ONE file and -p1 format - see drupal.org/patch

mehrpadin’s picture

Privet Dmitry,

Good points, thank you, I'll review them as soon as possible.

:)

mehrpadin’s picture

Duplicate removed.

dpovshed’s picture

The corrections looks harmless and useful.

@ardas can you please reformat your patch according to comment #2?

This would allow people (including me) to apply it right now and later post feedback here.

ardas’s picture

Version: 7.x-1.x-dev » 7.x-1.9-beta4
Status: Needs work » Active

Yes, we will do it.
Thank you for your help.

More patches are comming soon... I'm trying to make all superfish blocks to be cache compatible and don't load not needed JS files on pages where we don't have any superfish blocks.

mehrpadin’s picture

I've tried the patch; it didn't make a performance-related difference, and it was not working sometimes (probably a core issue but I'm not sure) so only added the #required parts, which was important enough! thank you Dmitry!

mehrpadin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.