To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Ticket #480 (closed defect: fixed)

Opened 19 months ago

Last modified 19 months ago

sfDoctrineActAsTaggable - Tag Widget Bug

Reported by: johnnyoffline Owned by: dordille
Priority: major Milestone: 1.4.1
Component: apostrophePlugin Version: 1.4
Keywords: tags Cc: tboutell, johnnyoffline
Symfony version: 1.4

Description

We found a bug and Tom helped to fix it.

Notes:
Dan, you use object_class down below but were not setting it when there is an object. I found zero instances of it ever being called without an object btw, although I could have missed something nutty

Change History

Changed 19 months ago by johnnyoffline

  • status changed from new to closed
  • resolution set to fixed

Committed revision 30233.

Before:

class taggableCompleteComponents extends sfComponents
{
	public function executeTagWidget()
	{
		if(empty($this->object))
		{
			$object_id = $this->getVarHolder()->get('object_id', false);
			$object_class = $this->getVarHolder()->get('object_class', false);
		
			if(!$object_id || !$object_class)
				throw new sfException("Must pass both object_id and object_class as option to this component.");
		
			$this->object = Doctrine::getTable($object_class)->findOneBy('id', $object_id);
		}
		
		if(!$this->object)
			throw new sfException("Object with specified parameters does not exist.");

   	$this->popular_tags = TagTable::getAllTagNameWithCount(null, array('model' => $object_class, 'sort_by_popularity' => true, 'limit' => 10));
		foreach($this->object->getTags() as $tag)
		{
			unset($this->popular_tags[$tag]);
		}
	}
}

After:

class taggableCompleteComponents extends sfComponents
{
	public function executeTagWidget()
	{
		if(empty($this->object))
		{
			$object_id = $this->getVarHolder()->get('object_id', false);
			$object_class = $this->getVarHolder()->get('object_class', false);
		
			if(!$object_id || !$object_class)
				throw new sfException("Must pass both object_id and object_class as option to this component.");
		
			$this->object = Doctrine::getTable($object_class)->findOneBy('id', $object_id);
		}
		else
		{
			$object_class = get_class($this->object);
			$object_id = $this->object->id;
		}
		
		if(!$this->object)
			throw new sfException("Object with specified parameters does not exist.");

   	$this->popular_tags = TagTable::getAllTagNameWithCount(null, array('model' => $object_class, 'sort_by_popularity' => true, 'limit' => 10));
		foreach($this->object->getTags() as $tag)
		{
			unset($this->popular_tags[$tag]);
		}
	}
}
Note: See TracTickets for help on using tickets.