Skip to content
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

FIX Linkfield sorting issue #262

Merged

Conversation

sabina-talipova
Copy link
Contributor

Description

The self::get() method returns list of specific Link types, because of this for each link type we reset and begin to increase Sort again.

Parent issue

@sabina-talipova sabina-talipova force-pushed the pulls/4/fix-sorting branch 2 times, most recently from 008ca5d to afd0c7e Compare March 26, 2024 01:51
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well locally.

$this->Sort = self::get()->filter([
$this->Sort = Link::get()->filter([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may have found a bug in PHP itself! self always refers to the class where the code is declared, so these should be identical. But for some reason the late static binding inside the get() call is still bound to the specific subclass.

We should probably avoid calling static methods in general if this sort of thing is going to happen.
Nice find.

tests/php/Models/LinkTest.php Show resolved Hide resolved
@GuySartorelli GuySartorelli merged commit bc1f7c9 into silverstripe:4 Mar 26, 2024
12 checks passed
@GuySartorelli GuySartorelli deleted the pulls/4/fix-sorting branch March 26, 2024 20:14
jareddreyerss pushed a commit to jareddreyerss/silverstripe-linkfield that referenced this pull request Mar 28, 2024
jareddreyerss pushed a commit to jareddreyerss/silverstripe-linkfield that referenced this pull request Mar 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants