Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMPB-1512 Mitigate OOM errors by maintaining a smaller array of properties to return from client_properties() when possible #499

Open
wants to merge 1 commit into
base: release/3.1.0
Choose a base branch
from

Conversation

lainvineyard
Copy link
Contributor

Pull Requests

Please explain the intent of your Pull Request.

🐛 Are you fixing a bug? Y

💻 Are you changing functionality? Y

Template

Description of the Change

A client was encountering OOM errors when trying to use the 'soldpending' property type option with the IMPress shortcodes. Investigating the situation, it was determined that this is happening because of the current behavior of the plugin where it loads all possible sold/pending listings even when only a part of them are necessary. The large number of listings associated with the account was thereby causing the issue.

The changes in this PR add optional arguments to /idx/idx-api.php client_properties() that, when used, allow for the plugin to maintain a smaller rolling list of properties that match what is needed to output the correct listings for the given request.

Note that the functionality when the "default" sort order is set is left unchanged in case there are clients that are intentionally retrieving all the listings at once for these widgets. This means a high-low, low-high or 'none' sort order will have to be set to see the changes in effect.

Verification Process

  1. Link your IMPress plugin to an account with thousands of soldpending listings associated with it.
  2. Add shortcode that tries to use the soldpending property type to a page, like [impress_property_carousel property_type="soldpending" max="100" order="high-low" autoplay="0" styles="1" new_window="1" ]
  3. Note that you encounter an OOM error.
  4. Apply the fixes in this PR, then try adding the shortcode again.
  5. The OOM error should now be resolved.

Release Notes

Fix: mitigated possibility of out of memory errors occurring when handling thousands of listings with the Showcase and Carousel widgets

Review

Pull Requests must have the sign-off of two other developers and at least one of these must be an IDX Broker team member.

…eturn from client_properties when possible

Reduce possibility of running into an OOM error by doing the following:

$max number of listings needed for the widget is used to limit the number of returned listings to that number

$user_agent_id is used to proactively filter listings out of the results

$max_sort is used together with $max to ensure the correct ordering of results is returned when low-high, high-low is set

Added 'none' as a sort order option for shortcodes if the order of the returned listings does not matter. Using none for the sort order lets the plugin return results much faster.

Note that functionality when 'default' is used for the sort order is kept the same to avoid disrupting the functionality of shortcode already being used on sites.
@lainvineyard lainvineyard changed the title Mitigate OOM errors by maintaining a smaller array of properties to return from client_properties() when possible IMPB-1512 Mitigate OOM errors by maintaining a smaller array of properties to return from client_properties() when possible Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant