Jump to content

Warning about page name changes


Zeka
 Share

Recommended Posts

Hi.

I have a hook to Pages::saveReady that changes page name and I get warning like 

Changed page URL name to "doc-1103" because requested name was already taken.

or

Warning, the name you selected "dokument" has been changed to "doc-1104".

I think that I have the same case like there https://github.com/processwire/processwire-issues/issues/648

Is it possible to somehow silence this warning? 

Thanks. 

Link to comment
Share on other sites

I am curious whether it makes a difference if you make the saveReady a "before" hook? My PageRenameOptions module does some renaming on saveReady using "before" and I don't think I have ever seen this error in this situation.

I might be totally off-base here but I thought it might be worth trying.

Link to comment
Share on other sites

51 minutes ago, adrian said:

I am curious whether it makes a difference if you make the saveReady a "before" hook?

OT, but saveReady is one of those methods where before and after hooks are equivalent: https://processwire.com/api/hooks/#before_or_after

Quote

Some hookable methods in ProcessWire have no implementation and exist purely for you to hook. Because hooks like this exist purely "to be hooked", it doesn't matter if you hook before or after them. Examples include Pages::saveReady which is called after it's been determined the page will definitely be saved, but right before it is done. Another is Pages::saved, which is called after a page has successfully been saved. These hooks provide more certainty and less need for error checking than hooking before or after Pages::save. You may see several other specific-purpose hooks like this in ProcessWire.

 

@Zeka, the solution @kongondo linked to will work, but if you think PW should not be giving warnings for deliberate name changes that aren't related to a sibling name clash then maybe you could add your voice the GitHub issue? The fix that Ryan applied does not seem ideal and a solution (I gave a possible one in the original issue comment) that focuses more on the specific scenario of a sibling name clash would be better I think.

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...