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

Use Model::findById() instead of Model::findByPk() #6916

Merged
merged 3 commits into from Mar 8, 2024

Conversation

leofeyer
Copy link
Member

As suggested in #6912 (comment).

@leofeyer leofeyer added the bug label Feb 20, 2024
@leofeyer leofeyer added this to the 5.3 milestone Feb 20, 2024
@leofeyer leofeyer self-assigned this Feb 20, 2024
@leofeyer leofeyer requested a review from a team February 20, 2024 12:27
@leofeyer leofeyer added the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Feb 20, 2024
@Toflar
Copy link
Member

Toflar commented Feb 20, 2024

Certainly for 5.4 and not 5.3.

@fritzmg
Copy link
Contributor

fritzmg commented Feb 20, 2024

We have added deprecations in bugfix versions in the past, haven't we?

@Toflar
Copy link
Member

Toflar commented Feb 20, 2024

If there was a need - where is it here?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 20, 2024

The earlier deprecations are added the better I thought, no?

@Toflar
Copy link
Member

Toflar commented Feb 20, 2024

It's just a super useless change affecting 123 files in a bugfix release that wouldn't harm merging only in 5.4 - that's all I'm saying.

@leofeyer
Copy link
Member Author

leofeyer commented Feb 20, 2024

Certainly for 5.4 and not 5.3.

No, 5.3 is correct. We have added #6912 to the 5.3 branch and this is just an alternative approach to fix the same inconsistency. There is no reason why one should be correct for Contao 5.3 and the other not.

Also, we certainly don't want the LTS version to use findByPk() and future versions to use findById(). This would make upstream merging unnecessarily complicated.

@leofeyer
Copy link
Member Author

But the issue is up for discussion. We might as well leave things as they are.

@ausi
Copy link
Member

ausi commented Feb 20, 2024

We’d have to deprecate Model::$strPk as well then, right?

Same with $GLOBALS['TL_DCA'][…]['config']['sql']['keys']['id'] = 'primary'; for any column that is not named id?
Although we probably shouldn’t, as we already use it for DCAs that don’t have a Model like tl_search_index for example.

@leofeyer
Copy link
Member Author

We’d have to deprecate Model::$strPk as well then, right?

Yes, we would.

@leofeyer
Copy link
Member Author

leofeyer commented Mar 7, 2024

As discussed in the Contao call, we want to use findById() instead of findByPk() but we do not want to deprecate the primary key logic.

@leofeyer leofeyer removed the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Mar 7, 2024
@leofeyer leofeyer added CI and removed bug labels Mar 8, 2024
@leofeyer leofeyer changed the title Deprecate the Model::findByPk() logic Use Model::findById() instead of Model::findByPk() Mar 8, 2024
@leofeyer leofeyer added bug and removed CI labels Mar 8, 2024
@leofeyer leofeyer merged commit 503bdbf into contao:5.3 Mar 8, 2024
17 checks passed
@leofeyer leofeyer deleted the fix/find-by-pk branch March 8, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants