Skip to content

[Issue] Corrected scope of _construct to protected #29643

Open
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #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 (*)

  • Pull request has a meaningful description of its purpose
    All commits are accompanied by meaningful commit messages
    All new or changed code is covered with unit/integration tests (if applicable)
    All automated tests passed successfully (all builds are green)

Activity

added
Priority: P4No current plan to fix. Fixing can be deferred as a logical part of more important work.
Severity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.
on Aug 18, 2020
linked a pull request that will close this issue on Aug 18, 2020
added this to the 2.5 milestone on Jan 25, 2021
added
Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch
Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
on Dec 21, 2022
github-jira-sync-bot

github-jira-sync-bot commented on Dec 21, 2022

@github-jira-sync-bot

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.

removed
Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
on Dec 21, 2022
github-jira-sync-bot

github-jira-sync-bot commented on Dec 21, 2022

@github-jira-sync-bot

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

m2-assistant

m2-assistant commented on Dec 21, 2022

@m2-assistant
Author

✅ 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.

moved this to Pull Request In Progress in Low Priority Backlogon Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: FrameworkComponent: CronIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedPriority: P4No current plan to fix. Fixing can be deferred as a logical part of more important work.Progress: PR in progressReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @dfelton@gabrieldagama@magento-engcom-team@engcom-Lima@github-jira-sync-bot

    Issue actions

      [Issue] Corrected scope of _construct to protected · Issue #29643 · magento/magento2