-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove redundant makeSlugUnique method overriding #3625
Remove redundant makeSlugUnique method overriding #3625
Conversation
BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly. Please keep in mind that:
Thank you! -- |
Apparently a month ago, on v8.0.5, eloquent-sluggable introduced this BC for us 😕 Merging this PR will make old code stop working (if in a rare situation devs update CRUD without updating eloquent-sluggable). I analysed I think we are safe to stop overriding this function and remove it completely. |
@promatik from code perspective it seems safe to don't override, my thinking here is why was it overriden to start with. It was to use Did you tested it ? If you did and it works I think we are safe to remove the function. Any other reason to override the function ? Let me know, |
Same here, when i used clone feature this error appears. |
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.
I'v just tested removing the function override and everything seems to work fine.
Tests in demo:
Product.php
model:
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\Sluggable;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\SluggableScopeHelpers;
class Product extends Model
{
use CrudTrait;
use HasTranslations, Sluggable, SluggableScopeHelpers;
public function sluggable(): array
{
return [
'description' => [
'source' => 'name',
'uniqueSuffix' => function() {
return '-2'.time();
}
],
];
}
Thanks,
Pedro
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.
@pxpm |
The inspection completed: No new issues |
I agree, it looks to me like that method is identical in our overwrite and the "before" in cviebrock/eloquent-sluggable@ca8c166#diff-0076c2a3786bba62c985d7d0220f2ab44266ad8d673df620b2789d8ffd7c0eb4R243 that @promatik tracked down. So removing it entirely should be fine. I have no idea why we had it in the first place... I expect we did have a reason though 😅 So let's be careful here. @pxpm / @promatik did you also test using the lowest possible versions of laravel and cviebrock, with this change? |
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.
I think we are safe to remove the override. I'v created branch https://github.com/Laravel-Backpack/CRUD/tree/backpack-dependencies-tests while doing this research.
This is what I did:
- Created a new
phpunit-dependencies.xml
config file that instead of loading thebackpack/crud
vendor autoload, loads the autoload in the "main project" and runs only the tests specific to dependencies. (cviebrock sluggable is only available in the main project, it's not a crud dependency). - Created a test that uses translatable slugs to test the functionality.
- Removed the override from backpack trait.
Tested with L8, downgraded Laravel down to 6 and the test passes in all 3 versions without the override.
To use the dependencies config while testing, run phpunit with vendor/bin/phpunit --testdox --configuration=phpunit-dependencies.xml
Let me know,
Pedro
Just to make sure of this, I dug both repos 😅 The original file was then updated, here and here, our wasn't. Those were minor changes, old laravel version support and bug fixes, so I believe this is safe to merge ✌ |
Ok let's do this 🤞 😅 |
\Cviebrock\EloquentSluggable\Services\SlugService::generateSuffix expects 4 arguments, but only 3 passed.