-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
sortBy('sort', 'desc') from template re-orders content #2475
Comments
In the accidental use, the entire sorting will lost and if it is a user who is not logged in, gets an error. This issue about conflicting https://github.com/getkirby/kirby/blob/3.3.4/src/Cms/PageActions.php#L725-L728 |
@lukasbestle Do you have any idea or solution on this issue? |
To be honest, I think that this is quite hard to fix in general. It's intended behavior that What we could do is to introduce a class-based blacklist (like So I'm not sure if we should rather add a warning to the docs that |
I think the main issue isn't so much that |
While this is a lot easier, the problem is that people tend not to read the docs or even understand what that means before the damage is done 😉 . +1 to change the name of the method to |
@distantnative I was testing it too 👍 Because I think it is confused by users (including me) whether it is a noun or a verb 🤔 |
I've done a few tests, it looks great for now 🎉 public function changeSort($position = null)
{
return $this->changeStatus('listed', $position);
}
/**
* @deprecated 3.3.5 Use `Page::num()` instead
*
* @return int|null
*/
public function sort($position = null)
{
deprecated('$page->sort() is deprecated, use $page->num() instead. $page->sort() will be removed in Kirby 3.5.0.');
return $this->num();
} |
We will also need to prepare a migration in code for users using the |
You are right! I agree that we should get rid of the So maybe we should instead completely deprecate the @afbora Regarding deprecation there are two things to keep in mind in general: Deprecations should ideally be done in minor versions (i.e. 3.4.0, not 3.3.5), otherwise there will suddenly be warnings for patch updates. Also the deprecation must point to the new method, which would be Regarding the |
@lukasbestle I appreciate you to explain any subject with detailed tips and tricks. I learn a lot thanks to you 👍 Btw can you label the issue? Is this a bug or enhancement? 😅 |
@manuelmoreale that is for files, not pages |
@distantnative I know but it's still confusing because of muscle memory 😄 |
Maybe it's a personal option but I find it confusing to have code written the same way that does different things in different contexts. In this example for example, coming from K2, |
I agree, @manuelmoreale - it's a bit unfortunate that for pages it's called Considering that, maybe we should proceed as suggested above, but instead of getting rid of I know this is a bit tricky since it is a breaking change, but I think it might be a good chance to unify the experience a bit (as @manuelmoreale pointed towards). |
I agree that it makes sense to unify the two classes in this regard. If we decide to do it, we should however first deprecate the current The question is: Wouldn't it make more sense to rename |
Not sure if first deprecating and then lat reintroducing it is really viable - sounds like a year-long timeframe to me. And I wouldn't touch actual content. |
Yes, that's true. To be honest, that's a reason for not doing it at all. Simply replacing the method in one go is not viable either. What we could do instead: Deprecating |
For sure it wouldn’t be ideal, but we have other breaking changes in 3.x releases too. Since it is a change towards a method that only returns something (not altering data or even content files), there wouldn’t be any danger of data loss or so. Having the file alias method could be a way. But since $file->sort() continues to exist, people will continue to use that and thus expect a $page->sort(). |
That's true. :)
The question is which method makes more sense in the long term. Having aliases in both ways ( So in my opinion we should just offer |
That said, I'd intuitively think at the Having
But as you both said, it's tricky to now change the behaviour of those methods. |
Interesting! I would have thought
In this issue we are discussing |
O yes I was just comparing
Totally. What I was referring to is the consistency of naming convention in general. I was using Anyway, to go back to the original topic: I'm personally in favour of using |
That's exactly the reason why I suggested to drop the |
New thought: The other aspect of getting the names between So ideally I'd suggest that In addition, maybe |
👍 However running each single call through
Do we really need consistency here? I'm all in for introducing that later, but not with a breaking-change. Better first deprecate the existing |
|
As the user class uses `sortBy()` internally, the order of calling the methods needs to be changed to avoid interference when testing the impersonation feature. #2475
As the user class uses `sortBy()` internally, the order of calling the methods needs to be changed to avoid interference when testing the impersonation feature. #2475
As the user class uses `sortBy()` internally, the order of calling the methods needs to be changed to avoid interference when testing the impersonation feature. #2475
As the user class uses `sortBy()` internally, the order of calling the methods needs to be changed to avoid interference when testing the impersonation feature. #2475
As the user class uses `sortBy()` internally, the order of calling the methods needs to be changed to avoid interference when testing the impersonation feature. #2475
@lukasbestle as far as I can see we did implement the solutions discussed here with 3.6.0-alpha - do you see anything missing? |
As far as I can tell, we solved this in 3.5 already. |
Describe the bug
using
->sortBy('sort', 'desc')
in a template on a collection of pages causes them to be re-numbered in the content folder.Example code:
I realize this is not the correct way to change the order of the pages, but the result seems like a bug that should be fixed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Template code should not change the content folder
Screenshots
Kirby Version
3.3.4
The text was updated successfully, but these errors were encountered: