Skip to content

Fix: guard REQUESTS_SILENCE_PSR0_DEPRECATIONS define to prevent constant collision#416

Open
N-M wants to merge 1 commit into
razorpay:masterfrom
N-M:fix/deprecated-constant-guard
Open

Fix: guard REQUESTS_SILENCE_PSR0_DEPRECATIONS define to prevent constant collision#416
N-M wants to merge 1 commit into
razorpay:masterfrom
N-M:fix/deprecated-constant-guard

Conversation

@N-M

@N-M N-M commented Jun 22, 2026

Copy link
Copy Markdown

Problem

Deprecated.php defines REQUESTS_SILENCE_PSR0_DEPRECATIONS unconditionally:

define("REQUESTS_SILENCE_PSR0_DEPRECATIONS", true);

If another package or the host environment has already defined this constant before the Composer autoloader runs, PHP throws a fatal error:

PHP Fatal error: Constant REQUESTS_SILENCE_PSR0_DEPRECATIONS already defined

A common case is WordPress, which defines this constant in its bundled Requests library before any plugin's autoloader is executed.

Fix

Wrap the define() with a !defined() guard — the same pattern already used in Razorpay.php in this package:

if (!defined("REQUESTS_SILENCE_PSR0_DEPRECATIONS")) define("REQUESTS_SILENCE_PSR0_DEPRECATIONS", true);

Closes #415

…ant collision

Unconditional define() causes a fatal error when the constant is already
defined by the host environment (e.g. WordPress core defines it in its
bundled Requests library before the Composer autoloader runs).

Razorpay.php in the same package already uses this guard correctly;
align Deprecated.php to match.

Fixes razorpay#415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated.php: unconditional define() causes fatal error when REQUESTS_SILENCE_PSR0_DEPRECATIONS is already defined

1 participant