ydb-platform / ydb-platform/ydb-php-sdk
feat: public way to check for an active transaction on Session
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 39
- Forks
- 19
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 2
Description
Describe the Feature Request
У Session сейчас нет публичного способа узнать, есть ли в данный момент активная транзакция — tx_id хранится как protected-поле без геттера. Единственный способ снаружи класса это выяснить — рефлексия по приватному полю.
Describe Preferred Solution
Минимальный публичный геттер вида Session::isInTransaction(): bool (или getTxId(): ?string), без изменения сигнатуры beginTransaction() и без введения отдельного объекта-транзакции — чисто аддитивное добавление.
Describe Alternatives
Более крупное решение — отдельный объект-транзакция вместо мутируемого tx_id на Session (так сделано в C++/Java/Python SDK: TTransaction::IsActive(), YdbTransaction.isActive(), TxContext.tx_id). Это ломает текущую сигнатуру beginTransaction() (сейчас возвращает голую строку) и требует отдельного обсуждения — не нужно для закрытия конкретно этой проблемы.
Related Code
Конкретный кейс, который к этому привёл: в ydb-doctrine при фиксе "одиночные запросы вне явной транзакции никогда не коммитятся" пришлось завести собственное параллельное private bool $inTransaction на Driver\YdbConnection, только чтобы решить, вызывать ли self-committing beginTx() или обычный query(). Это дублирует состояние, которое уже есть в Session, и может разойтись с ним, если tx_id когда-нибудь сбросится в обход Driver\YdbConnection.
Additional Context
PR с реализацией уже готов, см. ссылку ниже.
If the feature request is approved, would you be willing to submit a PR?
Yes — already submitted.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PHP Session class and its protected tx_id field, then inspect Driver\YdbConnection and the ydb-doctrine transaction flow described in the issue. Confirm the public state accessor exposes whether a transaction is active without changing beginTransaction(); done means callers no longer need reflection or duplicated transaction state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100