Development

#2938 ([PATCH] sfPropelActAsTaggableBehaviorPlugin: getPopulars and getAllWithCount does not use limit)

You must first sign up to be able to contribute.

Ticket #2938 (closed enhancement: fixed)

Opened 8 months ago

Last modified 4 months ago

[PATCH] sfPropelActAsTaggableBehaviorPlugin: getPopulars and getAllWithCount does not use limit

Reported by: Manel.Monguilod Assigned to: xavier
Priority: minor Milestone:
Component: sfPropelActAsTaggablePlugin Version: 1.0.10
Keywords: getPopulars getAllWithCount limit Cc:
Qualification: Accepted

Description

If you try to pass limit as option to getPopulars o to getAllWithCount, the limit is not used, and with getAll the limit is used. I think that limit is useful in this other 2 cases, because if not you are limited to app_tags_limit configuration in case of getPopulars, or you are not able to limit with getAllWithCount.

Im my case, I need sometimes to have several cloud tag with diferent number of items in each case.

To solve this you need to change getAllWithCount adding the control for the option limit. Change:

    if ($c == null)
    {
      $c = new Criteria();
    }

    if (isset($options['model']))
    {
      $c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
    }

with:

    if ($c == null)
    {
      $c = new Criteria();
    }

    if (isset($options['limit']))
    {
      $c->setLimit($options['limit']);
    }

    if (isset($options['model']))
    {
      $c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
    }

In this case, if you pass a option limit, this takes precedence over the configurated value. I think this will be useful for other people.

Change History

02/15/08 00:44:16 changed by xavier

  • status changed from new to closed.
  • resolution set to fixed.
  • qualification changed from Unreviewed to Accepted.

I patched the class, even if you could also create a new Criteria with the limit, and pass it as the first parameter to the method :)