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

Deprecation: #100071 - Magic repository findBy() methods #3600

Closed
sabbelasichon opened this issue Oct 13, 2023 · 0 comments · Fixed by #3943
Closed

Deprecation: #100071 - Magic repository findBy() methods #3600

sabbelasichon opened this issue Oct 13, 2023 · 0 comments · Fixed by #3943

Comments

@sabbelasichon
Copy link
Owner

Deprecation: #100071 - Magic repository findBy() methods

https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/12.3/Deprecation-100071-MagicRepositoryFindByMethods.html
.. include:: /Includes.rst.txt

.. _deprecation-100071-1677853787:

========================================================
Deprecation: #100071 - Magic repository findBy() methods

See :issue:100071

Description

Extbase repositories come with a magic :php:__call() method to allow calling
the following methods without implementing them:

  • :php:findBy[PropertyName]($propertyValue)
  • :php:findOneBy[PropertyName]($propertyValue)
  • :php:countBy[PropertyName]($propertyValue)

These have now been marked as deprecated, as they are "magic", meaning
that proper IDE support is not possible, and other PHP-related tool
functionality such as PhpStorm.

In addition, it is not possible for Extbase repositories
to build their own magic method functionality as the logic is already
in use.

Impact

As these methods are widely used in almost all Extbase-based extensions,
they are marked as deprecated in TYPO3 v12, but will only trigger a deprecation
notice in TYPO3 v13, as they will be removed in TYPO3 v14.

This way, migration towards the new API methods can be made without
pressure.

Affected installations

All installations with third-party extensions that use those magic methods.

Migration

A new set of methods without all the downsides have been added:

  • :php:findBy(array $criteria, ...): QueryResultInterface
  • :php:findOneBy(array $criteria, ...):object|null
  • :php:count(array $criteria, ...): int

The naming of the methods follows those of doctrine/orm and only
:php:count() differs from the formerly :php:countBy(). While all magic
methods only allow for a single comparison (propertyName = propertyValue),
those methods allow for multiple comparisons, called constraints.

findBy[PropertyName]($propertyValue) can be replaced with a call to findBy:

.. code-block:: php

$this->blogRepository->findBy(['propertyName' => $propertyValue]);

findOneBy[PropertyName]($propertyValue) can be replaced with a call to findOneBy:

.. code-block:: php

$this->blogRepository->findOneBy(['propertyName' => $propertyValue]);

countBy[PropertyName]($propertyValue) can be replaced with a call to count:

.. code-block:: php

$this->blogRepository->count(['propertyName' => $propertyValue]);

.. index:: PHP-API, NotScanned, ext:extbase

helsner added a commit that referenced this issue Dec 22, 2023
helsner added a commit that referenced this issue Dec 22, 2023
helsner added a commit that referenced this issue Jan 14, 2024
Resolves: #3600
---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Simon Schaufelberger <simonschaufi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant