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

Ignore tag's case #3139

Merged
merged 4 commits into from Sep 3, 2017
Merged

Ignore tag's case #3139

merged 4 commits into from Sep 3, 2017

Conversation

Kdecherf
Copy link
Member

@Kdecherf Kdecherf commented May 21, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? somewhat?
Deprecations? no
Tests pass? -
Documentation no
Translation no
Fixed tickets #2502
License MIT

Store tag labels in lowercase in order to prevent case-sensitive duplicates.

Non-lowercase tags already existing before this PR should still work as usual but any new tag will be saved in lowercase.

@j0k3r
Copy link
Member

j0k3r commented May 22, 2017

Are tests on MySQL green locally?

@Kdecherf
Copy link
Member Author

@j0k3r will check next week

@Kdecherf
Copy link
Member Author

Kdecherf commented May 31, 2017

Well... After checking the failing test I think I'm hitting a case sensitivity issue with databases again (thanks MySQL for being case-insensitive). I will rework the PR.

@Kdecherf
Copy link
Member Author

I updated the test for WallabagV1Import. Please review carefully @j0k3r @nicosomb @tcitworld

Reminder: this PR removes the ability to have upper chars in tag labels.

@nicosomb
Copy link
Member

Do we need a migration to update current tags?

* @param array $entitiesReady Entities from the EntityManager which are persisted but not yet flushed
* It is mostly to fix duplicate tag on import @see http://stackoverflow.com/a/7879164/569101
*/
public function assignTagsToEntry(Entry $entry, $tags, array $entitiesReady = [])
Copy link
Member

Choose a reason for hiding this comment

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

Hum, in 2.3 assignTagsToEntry has moved to Wallabag\CoreBundle\Helper\TagsAssigner.
Please update the correct one 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I blindly rebased my work without seeing that the whole method was missing...

@j0k3r j0k3r added this to the 2.3.0 milestone Jul 1, 2017
j0k3r
j0k3r previously approved these changes Jul 1, 2017
@Kdecherf
Copy link
Member Author

Kdecherf commented Jul 1, 2017

I need to add a specific test case for checking backward compatibility.

@j0k3r
Copy link
Member

j0k3r commented Jul 1, 2017

Go ahead 🙂

@Kdecherf
Copy link
Member Author

Kdecherf commented Jul 13, 2017 via email

@Kdecherf
Copy link
Member Author

I am going to resume work on this PR this evening.

@Kdecherf
Copy link
Member Author

The migration of tags is mostly done but I found another issue regarding unicode characters: PHP function strtolower() and SQL function LOWER() don't handle them. In this case wallabag can't merge héllo and hÉllo tags together.

Should we improve the support of unicode chars on the app side or should we just convert label like slug instead?

@Kdecherf
Copy link
Member Author

Well... Correction: only SQLite has issues with LOWER-ing unicode characters.

@Kdecherf
Copy link
Member Author

Please check the message of the commit introducing migration for detail. Note also that SQLite is unsupported by this migration.

Extensive test is required for migrating existing databases on MySQL and PostgreSQL.

Copy link
Member

@j0k3r j0k3r left a comment

Choose a reason for hiding this comment

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

The migration give too much risk for being able to put that PR into the 2.3.0 release I think.
What do you think @wallabag/core?

);

// Delete unused tags
$this->addSql("
Copy link
Member

Choose a reason for hiding this comment

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

What if the tag is associated to some entries?
We should handle the relation table entry_tag too 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the goal of the SQL block just above it

Copy link
Member

Choose a reason for hiding this comment

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

🤣 true.

@j0k3r
Copy link
Member

j0k3r commented Aug 17, 2017

Could you run a php-cs-fixer? And I think we'll be good to go 🙂

Kdecherf and others added 4 commits August 27, 2017 16:51
Fixes #2502

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This migration does not support SQLite as long as this engine does not
support Unicode in LOWER().

This migration starts by retrieving the list of lowercase tags which
need to be migrated. Then it retrieves the list of tags for each tags
from the previous step in order to migrate entries. It handles deletion
of empty tags. At the end the migration makes a full scan to update the
label of all remaining tags.

WARNING: THIS MIGRATION IS IRREVERSIBLE.

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
@j0k3r j0k3r merged commit 3af5d41 into wallabag:2.3 Sep 3, 2017
@j0k3r
Copy link
Member

j0k3r commented Sep 3, 2017

👏

@j0k3r j0k3r mentioned this pull request Sep 3, 2017
@Kdecherf Kdecherf deleted the 2502-tag-case branch November 19, 2017 13:46
Kdecherf added a commit that referenced this pull request Nov 27, 2017
Fix possible issue with special chars on #3139

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Kdecherf added a commit that referenced this pull request Dec 10, 2017
Fix possible issue with special chars on #3139

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
nicosomb added a commit that referenced this pull request Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants