Skip to:
Content

Opened 3 years ago

Closed 3 years ago

#3233 closed enhancement (fixed)

Cutdown the queries for Xprofile select/Multiselect field

Reported by: sbrajesh Owned by: sbrajesh
Milestone: 1.5 Priority: normal
Severity: Version: 1.5
Component: XProfile Keywords: has-patch
Cc: sbrajesh

Description

Hi,
Currently when we use select/multiselect field, buddypress makes one query per list item on the edit-profile/registration page.
It means, if we have 100 list items in the select field, it will do 100 queries.

here is a patch to fix it. With this patch, the no. of queries will not depend on the number of items in the list.

I have tested it on my current trunk version, please have a look.

Attachments (1)

xprofil-select-multiselect-field-patch.patch (2.6 KB) - added by sbrajesh 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 DJPaul3 years ago

Are you sure the bit under "Check for updated posted values, but errors preventing them from being saved first time" isn't needed? I've not tested the patch (yet).

comment:2 sbrajesh3 years ago

If we look at the original code, that section of code does not do anything which will have any effect on working. I am sure, it is not affecting the security but a second opinon will be much better. My main goal was putting

$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) );

outside the loop as it actually called the same thing every time. Please do test and let me know if we can improve further.
btw, we can do something similar for the checkboxes too(I really did not test the number of queries for checkboxses earlier, but seeing code, that seems also another candidate for change).

comment:3 DJPaul3 years ago

  • Milestone changed from Awaiting Review to 1.3

comment:4 djpaul3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4431]) Don't do multiple queries when editing xprofile select/radio/checkboxes. Fixes #3233, props sbrajesh

Note: See TracTickets for help on using tickets.