Fixed duplicated tags on PUT track tag groups
Change-Id: I1b26c1989f3d53b44206dacbf50b439ec6808030
This commit is contained in:
parent
013df1b675
commit
3312f91d1b
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use models\main\ITagRepository;
|
||||
use models\main\Tag;
|
||||
use App\Repositories\SilverStripeDoctrineRepository;
|
||||
@ -40,8 +42,8 @@ final class DoctrineTagRepository
|
||||
protected function getOrderMappings()
|
||||
{
|
||||
return [
|
||||
'id' => 'e.id',
|
||||
'tag' => 'e.tag',
|
||||
'id' => 'e.id',
|
||||
'tag' => 'e.tag',
|
||||
];
|
||||
}
|
||||
|
||||
@ -57,9 +59,9 @@ final class DoctrineTagRepository
|
||||
->from(\models\main\Tag::class, "t")
|
||||
->where('UPPER(TRIM(t.tag)) = UPPER(TRIM(:tag))')
|
||||
->setParameter('tag', $tag)
|
||||
->getQuery()->getOneOrNullResult();
|
||||
->getQuery()->getSingleResult();
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
catch(NoResultException $e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,8 @@ implements ISummitTrackTagGroupService
|
||||
$track_tag_group->clearAllowedTags();
|
||||
foreach ($data['allowed_tags'] as $str_tag) {
|
||||
$tag = $this->tag_repository->getByTag($str_tag);
|
||||
if($tag == null) $tag = new Tag($str_tag);
|
||||
if(is_null($tag))
|
||||
$tag = new Tag(trim($str_tag));
|
||||
$track_tag_group->addTag($tag);
|
||||
}
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ final class OAuth2TrackTagGroupsApiTest extends ProtectedApiTest
|
||||
* @param int $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function testUpdateTrackTagGroup($summit_id = 25){
|
||||
$new_track_tag_group = $this->testAddTrackTagGroup($summit_id);
|
||||
public function testUpdateTrackTagGroup($summit_id = 27){
|
||||
//$new_track_tag_group = $this->testAddTrackTagGroup($summit_id);
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'track_tag_group_id' => $new_track_tag_group->id,
|
||||
'track_tag_group_id' => 26,
|
||||
'expand' => 'allowed_tags,tag'
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user