Skip to content

Stop using getService for lexicon, registry, error, smarty, mail, and hashing - #21

Open
Ibochkarev wants to merge 6 commits into
3.xfrom
fix/15986-remove-getservice-core
Open

Stop using getService for lexicon, registry, error, smarty, mail, and hashing#21
Ibochkarev wants to merge 6 commits into
3.xfrom
fix/15986-remove-getservice-core

Conversation

@Ibochkarev

Copy link
Copy Markdown
Member

Что сделано

getService() deprecated, но core и менеджер по-прежнему использовали его как lazy-фабрику для встроенных сервисов. Этот PR заканчивает tiers 1–2 из плана modxcms#15986: перестать вызывать его для шести имён в core/src и manager.

Эта работа лежит на стеке MAB-03 (xPDO 3 через Composer, autoloading, меньше map-эры привычек). Здесь тот же направление для runtime-сервисов: регистрировать их в DI-контейнере / аксессорах вместо старого xPDO service locator.

Tier 1 — lexicon, registry, error

  • registerCoreServices() регистрирует registry, error и hashing во время initialize() (lexicon уже приходит из _initCulture).
  • Call sites используют $modx->services->get(…) или синхронизированные свойства $modx->registry / $modx->lexicon / $modx->error.

Tier 2 — smarty, mail, hashing

  • hashing eager (пути паролей нуждаются в нём).
  • getSmarty() / getMail() / getManagerTemplatePath() — канонические аксессоры; smarty/mail регистрируются при первом использовании.
  • Manager request форсирует путь шаблона темы; другие call sites держат first-wins через getSmarty($path).
  • modX::getService() по-прежнему работает для экстра/тестов и синхронизирует $modx->$name, когда сервис уже в контейнере.

Grep-gate для этих шести имён под core/src и manager пуст.

Как проверить

  1. rg "getService\s*\(\s*['\"](lexicon|registry|error|smarty|mail|hashing)" core/src manager → пусто
  2. Логин в менеджер, включая forgot-password / activation hash (registry)
  3. Отредактируйте/сохраните ресурс (блокировки используют registry)
  4. Откройте дашборд (виджеты используют smarty)
  5. Создайте/обновите пользователя с email-уведомлением (smarty tpl + mail)
  6. Смените пароль пользователя (hashing)
  7. CI PHPUnit / MySQL-проверки на этой ветке

Связанные

Совместимость

Экстра, всё ещё вызывающие getService() для этих имён, продолжают работать. Core предпочитает аксессоры и container/$modx->* свойства после нормализации.

Оригинал: modxcms#16985

Register modError during initialize next to registry (lexicon already
comes from _initCulture). Replace core/manager getService call sites
for those three services with the DI container or synced properties.

Part of the series planned on modxcms#15986 (tier 1).
Register hashing eagerly and mail/smarty as lazy shared DI services
during initialize, then replace remaining core/manager call sites so
tiers 1–2 of modxcms#15986 ship in one PR.
Extract _registerCoreServices, add getSmarty/getMail/getManagerTemplatePath,
drop duplicated smarty bootstraps and dead widget ensures, and simplify
Reload registry handling.
Do not pre-register mail/smarty (keeps getService param+property sync),
ensure widgets call getSmarty(), sync properties in modX::getService,
and resolve hashing on plain xPDO without touching a missing property.
@Ibochkarev Ibochkarev changed the title Перестать использовать getService для lexicon, registry, error, smarty, mail и hashing Stop using getService for lexicon, registry, error, smarty, mail, and hashing Aug 21, 2026
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.

1 participant