magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.37k stars 9.28k forks source link

[Issue] Corrected scope of _construct to protected #29643

Open m2-assistant[bot] opened 3 years ago

m2-assistant[bot] commented 3 years ago

This issue is automatically created based on existing pull request: magento/magento2#25537: Corrected scope of _construct to protected


Description

Corrects the scope of _construct() method in Magento\Cron\Model\ResourceModel\Schedule.php.

_construct() is intended to act as a "mock" constructor and not supposed to be accessed outside of the context of $this

Fixed Issues (if relevant)

None.

Manual testing scenarios (*)

No tests performed. However I did perform a scan of the code base to ensure _construct() is never currently called outside of the context of $this.

grep -r \>_construct .
./lib/internal/Magento/Framework/View/Element/AbstractBlock.php:        $this->_construct();
./lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php:        $this->_construct();
./lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php:        $this->_construct();
./lib/internal/Magento/Framework/Model/AbstractModel.php:        $this->_construct();
./lib/internal/Magento/Framework/Data/Form/AbstractForm.php:        $this->_construct();
./app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php:        $this->_construct();

Questions or comments

This should really be a PR into 2.4-develop as this is a non-backwards compatible change. However no such branch exists for me to open a PR to.

While this does not break any functionality within Magento itself, it is potentially possible that developers have (against best practices) performed in their code something similar to the following:

<?php

namespace VendorName\ModuleName\Model\FooBar;

class BadPractice
{
    private $schedule;

    public function __construct(\Magento\Core\Model\Cron\ResourceModel\Schedule $schedule)
    {
        $this->schedule = $schedule;
    }

    public function notSureWhyAnyoneWouldEverDoThis()
    {
        $this->schedule->_construct();
    }

    // ... remaining class contents...
}

Contribution checklist (*)

github-jira-sync-bot commented 1 year ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-7519 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.