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!
| Comment | File | Size | Author |
|---|---|---|---|
| superfish.admin_.inc_.patch | 27.68 KB | ardas | |
| superfish.module.patch | 28.64 KB | ardas |
Comments
Comment #1
neochief commentedLooks good for me.
Comment #2
andypostpatch should live in ONE file and -p1 format - see drupal.org/patch
Comment #3
mehrpadin commentedPrivet Dmitry,
Good points, thank you, I'll review them as soon as possible.
:)
Comment #4
mehrpadin commentedDuplicate removed.
Comment #5
dpovshed commentedThe 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.
Comment #6
ardas commentedYes, 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.
Comment #7
mehrpadin commentedI'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
#requiredparts, which was important enough! thank you Dmitry!Comment #8
mehrpadin commented