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

Fix API creating tag duplicates #10270

Merged
merged 8 commits into from Nov 11, 2021

Conversation

patrykgruszka
Copy link
Member

@patrykgruszka patrykgruszka commented Jul 19, 2021

Q A
Branch? "features"
Bug fix? yes
New feature? no
Deprecations? no
BC breaks? no
Automated tests included? yes
Related user documentation PR URL
Related developer documentation PR URL
Issue(s) addressed

Description:

Creating new tags through API with special characters (e.q ", ') or whitespace in the beginning/end of the string causes duplicates.

Relates to #6057 #7741

Steps to test this PR:

  1. Apply this PR
  2. Create new tag with API POST /api/tags/new with data:
{
    "tag": "hello'world"
}
  1. Note the ID and repeat previous request with same data
  2. Only one tag should be created, second call should return the same tag ID

@cla-bot cla-bot bot added the cla-signed The PR contributors have signed the contributors agreement label Jul 19, 2021
@codecov
Copy link

codecov bot commented Jul 19, 2021

Codecov Report

Merging #10270 (9fed0e0) into 4.0 (4cb5404) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                4.0   #10270      +/-   ##
============================================
+ Coverage     43.29%   43.31%   +0.02%     
+ Complexity    34533    34532       -1     
============================================
  Files          2062     2062              
  Lines        115624   115647      +23     
============================================
+ Hits          50060    50096      +36     
+ Misses        65564    65551      -13     
Impacted Files Coverage Δ
app/bundles/LeadBundle/Entity/Tag.php 100.00% <100.00%> (ø)
app/bundles/LeadBundle/Entity/TagRepository.php 35.29% <100.00%> (-1.25%) ⬇️
...les/LeadBundle/Controller/Api/TagApiController.php 100.00% <0.00%> (+9.09%) ⬆️
...les/CoreBundle/EventListener/ExceptionListener.php 44.44% <0.00%> (+33.33%) ⬆️
...dles/CoreBundle/Controller/ExceptionController.php 41.37% <0.00%> (+41.37%) ⬆️

@npracht npracht added API Anything related to the API bug Issues or PR's relating to bugs tags Anything relating to tags labels Jul 22, 2021
@RCheesley RCheesley changed the base branch from features to 4.0 September 7, 2021 13:49
kuzmany
kuzmany previously approved these changes Oct 12, 2021
Copy link
Member

@kuzmany kuzmany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍
Unit test included 👍
Works for me 👍

@kuzmany kuzmany added ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged pending-test-confirmation PR's that require one test before they can be merged and removed ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged labels Oct 12, 2021
@mabumusa1 mabumusa1 self-requested a review November 9, 2021 12:20
mabumusa1
mabumusa1 previously approved these changes Nov 9, 2021
Copy link
Member

@mabumusa1 mabumusa1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, there are unit tests.

I think this PR is good to be merged

@mabumusa1 mabumusa1 added ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged and removed pending-test-confirmation PR's that require one test before they can be merged labels Nov 9, 2021
@npracht npracht added this to the 4.0.2 milestone Nov 9, 2021
@dennisameling dennisameling dismissed stale reviews from mabumusa1 and kuzmany via 3158087 November 11, 2021 10:57
Copy link
Member

@dennisameling dennisameling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the decreased code coverage is that, while a bunch of tests were added for the TagApiControllerFunctionalTest, it doesn't increase the code coverage as these things are routed through the CommonApiController, which is the same for many API endpoints and not specific to the TagApi. There is some specific error handling in TagApiController which wasn't covered by a test yet, so I just added one for that.

Merging now 👍🏼

@dennisameling dennisameling merged commit e59da08 into mautic:4.0 Nov 11, 2021
RCheesley added a commit that referenced this pull request Nov 22, 2021
* Update Mautic version in GitHub issue form

* Change webhook_url column type to text (#10407)

* Fix points in webhook after form submission (#10144)

* Fix points in webhook after form submission

* CS fixer

* Add unit tests

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix array parameters from tracking query (#10404)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Asset language as required (#10406)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* add missing attribute (#10355)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Add no_unused_imports to CS fixer (#10317)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix bad date format. (#9767)

Signed-off-by: Giovanni Mascellani <giovanni@mascellani.eu>

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix form issues with file type field (#9233)

* Fix form issues with file type field

* Fix unit tests

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Video form select optimization (#10276)

* Optimizing of loading of forms into a gated video select box

Now we are loading only the ID and label instead of all columns and it will also load only published forms

* Correction of the test folder

* Container has become a static property 🤷

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Prevent exception when creating a new field when background processing is enabled (#9761)

* Add missing properties for custom field responses

* Give option to api controllers to handle saving the entity

* Return 202 (accepted) when fields are processed in the background rather than throwing an uncaught exception

* Added AbstractMauticTestCase::$configParams property

* Removed 'charLengthLimit' from LeadField::loadApiMetadata()

Co-authored-by: Alan Hartless <alan@devkardia.com>
Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Re-apply the patch from the PR #10462 (#10482)

Co-authored-by: Adrian Schimpf <adrian@idea2.ch>

* bumping to version 4.0.1

* Update PR template to reflect new branching strategy (#10440)

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Bump version to 4.0.2-beta (#10520)

* Bump php-cs-fixer from 2.16.10 to 2.19.2 (#10519)

* Bump php-cs-fixer from 2.16.10 to 2.19.2

* Run fixcs command on whole codebase

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix Doctrine metadata cache handling during installation (#10481)

* Don't clear cache during installation

* Add tests to increase coverage

* Fix CS

* Fix UI installer by clearing ORM metadata cache

* Update Codecov GH Action to v2 (#10530)

* [BUGFIX] Removed apostrophe from email validation (#10413)

* [BUGFIX] Removed apostrophe from email validation

* [BUGFIX] altered tests for apostrophe check

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Bump version to 4.0.2-rc to fix CodeCov (#10559)

* Removed composer v1 requirement in README (#10586)

* Salesforce: Check DNC status (#9956)

Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix campaign membership syncing when an issue such as api limits occur (#7514)

* Only recognize integration entity entries for contacts that still exist in Mautic

* CS fix

* Fixed issue that caused date/time to be cached for campaign membership when something in fetching unknown contacts fails such as an api limit error (in getLeads)

* CS fix

* Fixed missing parameter

* Fixed CS

* Implement function test to improve code coverage.

* Improve the test.

* Add strict types.

* Add more assertions.

* fix failing test case

Co-authored-by: Anton Vlasenko <vlasenko.anton@gmail.com>
Co-authored-by: Dennis Ameling <dennis@dennisameling.com>
Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Saurabh Gupta <saurabh.gupta@acquia.com>

* Fix date range  in segments and reports does not trigger ajax request (#10421)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Set install_source to DDEV for local dev (#10595)

* Fix process string in contact's audit log (#10061)

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix display zero values in reports (#10167)

Co-authored-by: Joey Keller <jos0405@gmail.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix SES multiple unsubscribe header (#10557)

Co-authored-by: Mohammad Abu Musa <m.abumusa@gmail.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix email translations lost and overwritten by parent (#10525)

* Fix email translations lost and overwritten by parent email content

* Add unit tests

* CS fixer

* Remove SORTARRIVAL define

* Test code coverage increased

* CS fix

* CS fix

* CS fix

* CS fix

Co-authored-by: Mohit Aghera <mohit.beta@gmail.com>
Co-authored-by: fedys <miroslav.fedeles@gmail.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix dashboard widget Sent email to contacts (#10166)

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Place the .gitignore in the project root, not the webroot (#10300)

* Place the .gitignore in the project root, not the webroot

* Update composer.json

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Bring .github changes over to 4.0 (#10597)

* Split up monorepo jobs (#10600)

* Fix trigger inactive schedule decision after scheduled event (#9486)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling <dennis@dennisameling.com>
Co-authored-by: Mohit Aghera <mohit.beta@gmail.com>

* Focus: hide form If we use notice type of popups  (#10527)

* Focus: hide form If we use notice type

* Added unit tests

* Remove comment

* remove mixed from tests

according to John's feedbacks

Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix salesforce sync companies even are disabled (#10497)

* Fix salesforce sync companies even are disabled

* Fix PHP Stan report

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* fix JS (#10495)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix Invalid clickthrough value exception (#10444)

* Fix Invalid clickthrough value exception

* Fix Invalid clickthrough value exception

* Add unit tests

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* [BUGFIX] using preg_grep because Contents will be an array (#10308)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* enclosing sender name with double quotes (#10326)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix form submit messages length (#10266)

* Allow longer form submit message than 191 characters

* Review changes

* Run cs-fixer on migrations

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix A new entity was found through the relationship 'Mautic\LeadBundle\Entity\Company#owner (#9328)

* MAUT-3669 / Salesforce syncing fails with "A new entity was found through the relationship 'Mautic\LeadBundle\Entity\Company#owner'"

* Fix inability to update Mautic lead fields if the value that is coming from the integration is empty.

* Covering the new methods with tests

* Moving the new test to the correct dir

* Revert "Fix inability to update Mautic lead fields if the value that is coming from the integration is empty."

This reverts commit 392a3e1

* Fixed CompanyObjectHelperTest

Co-authored-by: Anton Vlasenko <vlasenko.anton@gmail.com>
Co-authored-by: John Linhart <admin@escope.cz>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Add select/multiselect to NormalizedValueDAO from internal object (#9919)

* Add select/multiselect to FieldDAO from internal object

* Added unit test for IntegrationBundle/FieldHelper:getNormalizedFieldType

Co-authored-by: Julien Ulm <jul@webmecanik.com>
Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Some winner criteria not working properly in A/B Tests (#9936)

* Fixed lowest bounce rate calculation for A/B testing.

* Fixed download rate not working for emails A/B testing.

* Fixed test case for lowest bounce rate calculation for A/B testing.

* Fixed and added test cases for asset redirect.

* Fixed an edge case where 0 bounces were not being considered

* Fixed A/B stats pop up box not closing.

* Fixed failing test case.

* update row.html.php with typo in translation string

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Add unit test for extractCompanyDataFromImport (#10064)

Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Unable to perform "Change campaign" Action for removing a contact from one and adding to another campaign (#10151)

* Source contact was not removed from campaign

* remove extra file

Co-authored-by: Zdeno Kuzmany <zdeno@kuzmany.biz>
Co-authored-by: Joey Keller <jos0405@gmail.com>
Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix dashboard report line graphs (#10209)

* Fix dashboard report line graphs

* Functional test

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: fedys <miroslav.fedeles@gmail.com>
Co-authored-by: Joey Keller <jos0405@gmail.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* Fix sync salesforce if company has name with html entity code of singlequote (#10535)

* fix(escapequeryvalue): moved escape single quote after the decode

If in db i saved a value with html entity of single quote ( &#39; ), escape of single quote doesn't works,
then decode convert html entity in single quote and the query breaks. To avoid this bug i move the escape
of single quote after the decode

* test(salesforceapitest): update test with the new case of html entity

* Fix API creating tag duplicates (#10270)

* Fix API tag duplicates

* Add tag API controller functional test

* Add ApiController test

Co-authored-by: Mohammad Abu Musa <m.abumusa@gmail.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>
Co-authored-by: Dennis Ameling (he/him) <dennis.ameling@leap.ac>

* Fix duplicate entry for key campaign_rotation (#9639)

* Fix Duplicate entry ... for key campaign_rotation

* Add EventLoggerTest::testHydrateContactRotationsForNewLogs()

- Very simple test since repository should be tested spearately

* Add unit tests

* Fix getIpAddress in testBuildLogEntry

Co-authored-by: Dennis Ameling <dennis@dennisameling.com>
Co-authored-by: Julien Ulm <jul@webmecanik.com>
Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix form field campaign condition with special character in value (#10470)

* Fix form field campaign condition with special character in value

* Test added to cover comparing form field values with an apersand

* Setting undefined keys

* Have to drop the form submission table that is autogenerated

* Temporary test skip

* Adding checks and debug info to problematic tests

* Using dynamic campaign ID in a failing test

* Adding more details to the failing test

* Using dynamic IDs for contacts in a fragile test

* Make email unique for the test as if John Doe was ever created by another test before this test will fail.

* Use dynamic IDs in a fragile test

* One more place where to use dynamic ID

* Replacing forgotten hard-coded ID

* Select the right audit log record

Co-authored-by: John Linhart <admin@escope.cz>
Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>

* update getManager methodcall (#10589)

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>

* Fix set values from properties for state field (#10486)

* Fix set values from properties for state field

* Fix If sortable use wrong input format

* Revert back return value for normalize values

* Coverint CustomFieldValueHelper::setValueFromPropertiesList with tests

Co-authored-by: Ruth Cheesley <ruth.cheesley@acquia.com>
Co-authored-by: John Linhart <admin@escope.cz>

* Bump version to 4.0.2-stable

* Regenerating  phpstan baseline to merge 4.0 to 4.x

Co-authored-by: Zdeno Kuzmany <zdeno@kuzmany.biz>
Co-authored-by: Mohammad Abu Musa <m.abumusa@gmail.com>
Co-authored-by: Giovanni Mascellani <giovanni@mascellani.eu>
Co-authored-by: John Linhart <admin@escope.cz>
Co-authored-by: Miroslav Fedeleš <miroslav.fedeles@gmail.com>
Co-authored-by: Alan Hartless <alan@devkardia.com>
Co-authored-by: Mohit Aghera <mohit.beta@gmail.com>
Co-authored-by: Adrian Schimpf <adrian@idea2.ch>
Co-authored-by: Dennis Ameling (he/him) <dennis@dennisameling.com>
Co-authored-by: Leon <55587275+oltmanns-leuchtfeuer@users.noreply.github.com>
Co-authored-by: Norman Pracht - Webmecanik <npr@webmecanik.com>
Co-authored-by: Anton Vlasenko <vlasenko.anton@gmail.com>
Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
Co-authored-by: Saurabh Gupta <saurabh.gupta@acquia.com>
Co-authored-by: Joey Keller <jos0405@gmail.com>
Co-authored-by: Patryk Gruszka <patryk.gruszka@comarch.pl>
Co-authored-by: Nick Veenhof <nick.veenhof@gmail.com>
Co-authored-by: Lukas Günther <lukas.guenther@pm.me>
Co-authored-by: Pedro Egg <pedroegg123@yahoo.com.br>
Co-authored-by: julienWebmecanik <79137416+julienWebmecanik@users.noreply.github.com>
Co-authored-by: Julien Ulm <jul@webmecanik.com>
Co-authored-by: Tejas Navghane <ts.navghane@gmail.com>
Co-authored-by: Saurabh Gupta <48244990+dadarya0@users.noreply.github.com>
Co-authored-by: Alfredo Arena <50916237+alfredoct96@users.noreply.github.com>
Co-authored-by: Dennis Ameling (he/him) <dennis.ameling@leap.ac>
indorock pushed a commit to unikrn/mautic-fork that referenced this pull request Nov 26, 2021
* official/4.0: (40 commits)
  Bump version to 4.0.2-stable
  Fix set values from properties for state field (mautic#10486)
  update getManager methodcall (mautic#10589)
  Fix form field campaign condition with special character in value (mautic#10470)
  Fix duplicate entry for key campaign_rotation (mautic#9639)
  Fix API creating tag duplicates (mautic#10270)
  Fix sync salesforce if company has name with html entity code of singlequote (mautic#10535)
  Fix dashboard report line graphs (mautic#10209)
  Unable to perform "Change campaign" Action for removing a contact from one and adding to another campaign (mautic#10151)
  Add unit test for extractCompanyDataFromImport (mautic#10064)
  Some winner criteria not working properly in A/B Tests (mautic#9936)
  Add select/multiselect to NormalizedValueDAO from internal object (mautic#9919)
  Fix A new entity was found through the relationship 'Mautic\LeadBundle\Entity\Company#owner (mautic#9328)
  Fix form submit messages length (mautic#10266)
  enclosing sender name with double quotes (mautic#10326)
  [BUGFIX] using preg_grep because Contents will be an array (mautic#10308)
  Fix Invalid clickthrough value exception (mautic#10444)
  fix JS (mautic#10495)
  Fix salesforce sync companies even are disabled (mautic#10497)
  Focus: hide form If we use notice type of popups  (mautic#10527)
  ...

# Conflicts:
#	composer.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Anything related to the API bug Issues or PR's relating to bugs cla-signed The PR contributors have signed the contributors agreement ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged tags Anything relating to tags
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants