Posted by tpainton on July 23, 2011 at 9:53pm
2 followers
Jump to:
| Project: | Short URL |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi, great module. I was looking over the code and was confused by the following on line 242
<?
//-- Let modules alter final (shortened) URL if/as necessary
$hook = 'shorturl_shortenedurl_alter';
foreach (module_implements($hook) as $module) {
$func_name = $module .'_'. $hook;
$encoded = $func_name($encoded, $long_url);
}
?>Could we do it a little more drupalish by using module_invoke_all?
<?
$encoded = module_invoke_all('shorturl_shortenedurl_alter', $encoded, $long_url);
?>They both seem to do essentially the same thing but the later in a more drupalish way. I figure I am overlooking something..
Comments
#1
Using module_invoke_all doesn't allow non-objects to be altered by reference because it uses call_func_user_array(). If this is an alter, then you should be using drupal_alter('shorturl_shortenedurl', $encoded, $long_url);
#2
AHHHHH! I was having some issues making this work and now I know why. I guess come to think of it, I have never really used module_invoke_all to alter anything.. I just assumed it would work.
I am using this to shorten secure urls and I realized that in the process of creating a facebook app that the first url is the 'public', the second is the 'private'. It clicked that someone who knew the base mapping (by simply looking at your module ) could determine the private url, by knowing the public url then calculating out the next or previous in sequence (the urls are created in a loop). I can't think of a way to avoid this with perms, so I needed to alter the base mapping to be something no one knew.. Using drupal_alter, this now should be possible. I think.
Feature request then is to add a call to drupal_alter to the shorturl_base_encode_mapping() function so users can change the array for security purposes.