Skip to content

[Issue] Modify createClassDefinition to include application mode #40571

@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #40567: Modify createClassDefinition to include application mode


Disable runtime code generation in production mode

Description

This patch stops Magento from generating Interceptors, Factories, and Proxies at runtime when running in production mode.

In production, all generated classes must be created beforehand by bin/magento setup:di:compile. If they are missing (for example after generated/code is cleared during deployment), Magento should fail with a clear error instead of generating them on the fly.

Changes

  • DefinitionFactory: Registers the Generator Autoloader only when the application mode is not production.
  • ObjectManagerFactory: Passes the application mode from deployment config into createClassDefinition().

Behaviour

Mode Generator Autoloader Runtime generation
developer Registered Yes
default Registered Yes
production Not registered No

Requirements

  • Run bin/magento setup:di:compile during deployment before serving traffic.
  • Ensure generated/code is populated before going live.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions