mfrh_url_renamed action called twice with different URLs
-
The action
mfrh_url_renamed
is called twice in a row incall_hooks_rename_url()
with different arguments and no indication to the action function that there’s a difference.I think that the action hooks should be renamed, combined, or passed some argument that tells the respective functions what’s going on. Personally, I’d combine them into a single call with all of the parameters:
do_action( 'mfrh_url_renamed', $post, $orig_image_url, $new_image_url, $this->clean_url( $orig_image_url ), $this->clean_url( $new_image_url ) );
Of course, developers should be warned about this change in a advance.
ALSO,
call_hooks_rename_url()
is called bycall_post_actions()
for the full-size image, and then for each thumbnail, triggering themfrh_url_renamed
action (twice) for each thumbnail, without passing any argument to indicate that this is a thumbnail, or which thumbnail it is.I suggest passing a
$size
argument tocall_hooks_rename_url()
, which will then also be passed bydo_action()
to themfrh_url_renamed
action functions.For context, I’m updating meta data in the image’s parent post, which only needs to be done once for the full-size image, and my action function has to figure out that it’s being called with absolute URLs with no thumbnail size in the file name before it decides to continue processing.
Side comment: the variable
$post
and names likecall_post_actions()
are confusing, because in actual fact, they’re dealing with attachments. The global$post
variable is an object, but in this context, it may be an array, which means that downstream functions, like those triggered by action, have to figure this out before proceeding correctly.
- The topic ‘mfrh_url_renamed action called twice with different URLs’ is closed to new replies.