Opened 10 years ago
Closed 10 years ago
#5742 closed defect (bug) (fixed)
Cannot modify $allowedtags per xProfile field type
Reported by: | needle | Owned by: | djpaul |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Extended Profile | Keywords: | has-patch |
Cc: | needle@…, vivek@… |
Description
I've written a plugin that creates a custom field type and have discovered that I cannot modify $allowedtags per xProfile field type, but only globally.
To allow this, it seems to me that $this->field_id
and not $this->id
should be passed to the xprofile_data_value_before_save
filter in BP_XProfile_ProfileData->save()
, given that xprofile_sanitize_data_value_before_save()
expects the second parameter to be $field_id
. However, this value is not used in the function, nor is it passed on to subsequent filters where it could be used to discover the field type.
I'm attaching a patch which would allow the field type to be discoverable by passing the $field_id
onwards.
Attachments (2)
Change History (7)
#2
@
10 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from Awaiting Review to 2.1
Boone's 2nd idea sounds good.
#3
@
10 years ago
- Cc needle@… added
- Keywords has-patch added; needs-patch removed
Thanks for the feedback Boone. Sorry for the delay - was off work last week.
I appreciate the need to keep filter signatures the same for existing plugins but I cannot seem to find a situation where $this->id
actually has a value on save. I therefore suspect it would be safe to replace it with $this->field_id
which is populated. Nevertheless, I've created a new patch to reflect your concerns - as you rightly say, passing $this
is ultimately more flexible and your structure neatly sidesteps the issue.
I like the idea of this patch, and am happy to do something to make it easier for plugins to adjust the allowedtags array on a more case-by-case basis, but I have a few concerns about this patch as it stands.
$field_id
.because
xprofile_sanitize_data_value_before_save()
already takes a third parameter (the somewhat odd$reserialize
This leaves us with two options:
xprofile_sanitize_value_before_save()
, and pass a true value to the callback viaadd_filter()
:plus the necessary changes to
xprofile_data_value_before_save
I'm leaning toward 2 as the less intrusive option. needle, can you double check my logic and let me know what you think?