Skip to content

Suggestion: post slug should not been overidden #1333

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

Closed
ecourtial opened this issue May 5, 2022 · 5 comments
Closed

Suggestion: post slug should not been overidden #1333

ecourtial opened this issue May 5, 2022 · 5 comments

Comments

@ecourtial
Copy link
Contributor

👋

In this line:

if (null !== $postTitle = $post->getTitle()) {

We see that the slug is always created/updated if the title is not empty.
Issue: when editing a post which has already been published and indexed by search engines, it could trigger a side effect if you change the title.

I suggest:

if (null === $post->getSlug()) {
$post->setSlug($this->slugger->slug($post->getTitle())->lower());
}`

@bocharsky-bw
Copy link
Contributor

Makes sense to me 👍

@javiereguiluz
Copy link
Member

In a real application I'd 100% agree with you; here it might be debatable because it's a demo application that needs to be realistic but not a completely real app.

In any case, since the proposed change would be small and easier to understand to people reading the code, let's do it!

@ecourtial would you be willing to submit a pull request with this change? Thanks!

@ecourtial
Copy link
Contributor Author

@javiereguiluz
Allright I will create the PR soon.

@ecourtial
Copy link
Contributor Author

@javiereguiluz Done.

javiereguiluz added a commit that referenced this issue May 14, 2022
This PR was merged into the main branch.

Discussion
----------

Post slug is no longer overridden

See #1333

Commits
-------

68b0afe Post slug is no longer overridden
@javiereguiluz
Copy link
Member

Fixed in #1338. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants