Skip to content

[NFR]: Replace globals_get/globals_set with Settings::get/Settings::set #16884

@niden

Description

@niden

Summary

All calls to globals_get() and globals_set() for known ORM/DB settings keys should be replaced with Settings::get() and Settings::set() from Phalcon\Support\Settings.

Motivation

Settings::get() checks PHP-level overrides first, then falls back to globals_get(). Settings::set() stores values at the PHP level only and does not call globals_set(). This prevents settings from one project leaking into another when they share the same PHP worker process.

How This Will Be Fixed

Each of the 9 affected .zep files will be updated as follows:

  1. Add use Phalcon\Support\Settings; to the file's imports.
  2. Replace every globals_get("key") call (for a known Settings key) with Settings::get("key").
  3. Replace every globals_set("key", value) call with Settings::set("key", value).

The largest change is in phalcon/Mvc/Model.zep, where the setup() method sets ~15 ORM keys via globals_set() and ~36 read sites use globals_get() throughout the class.

Files to Change

File globals_get globals_set
phalcon/Db/Adapter/AbstractAdapter.zep 0 2
phalcon/Mvc/Model/Behavior/SoftDelete.zep 1 0
phalcon/Mvc/Model/Manager.zep 2 0
phalcon/Mvc/Model/MetaData/Stream.zep 1 0
phalcon/Mvc/Model/Query/Builder.zep 1 0
phalcon/Mvc/Model/Resultset/Complex.zep 1 0
phalcon/Mvc/Model/Resultset/Simple.zep 1 0
phalcon/Mvc/Model/Resultset.zep 1 0
phalcon/Mvc/Model.zep ~36 15
Total ~44 17

Excluded Files

The following files use globals_get("warning.enable", ...) which is a transient error flag (not a Settings key) and should remain unchanged:

  • phalcon/Annotations/Adapter/Stream.zep
  • phalcon/Storage/Adapter/Stream.zep
  • phalcon/Storage/Serializer/Igbinary.zep
  • phalcon/Storage/Serializer/Php.zep
  • phalcon/Support/Settings.zep (the globals_get calls here are the implementation itself)

Metadata

Metadata

Assignees

Labels

5.0The issues we want to solve in the 5.0 releasenew feature requestPlanned Feature or New Feature Request
No fields configured for Feature.

Projects

Status
Released

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions