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
Patch too many queries sluggable #485
Patch too many queries sluggable #485
Conversation
Do not merge now, @Divi found a bug, we need to patch it before merge |
Alright ;) |
There is a problem with the method makeSlugUnique, indeed, when you choose just one column to sluggable and if this column can be exists many time in the database, the makeSlugUnique will be launched as many times that you have a line with the same column value. For exemple, if you have a column "label", and a categoy with label value : "Home", now try to insert new row 100 times with the label value "Home", the makeUniqueSlug with be launched n+1 times at each row. So, I changed the method : try one time without ending separator, and if the line already exists, I try one more time but with the ending sepator and the count + 1 times of the line exists. So two queries max per line. Miss PHP Doc' Fix LIKE condition Some fixes when update object & without pattern Fix method name Oops... fix count query Fix object without pattern Sorry, can't launch test myself atm.
Wait for travis to run test but it should be good now :) |
@willdurand you can merge this PR ;) all green |
Patch too many queries sluggable
Thank ou guys. |
this fix issue introduced by PR #485
|
||
foreach ($matches[1] as $key => $match) { | ||
|
||
$column = $this->getTable()->getColumn($this->underscore(ucfirst($match))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks conjunction with DelegateBehavior
, where a column of the pattern is provided by the target class ("parent") and not by this class.
This PR replace #447
I squashed @Divi commits, fix CS.
I added test to prove that MakeUniqSlug was doing n query where n is the number of duplicate slug.