Skip to content

Add smart-process read contracts and fix CRM type deletion - #729

Open
camaxtly wants to merge 1 commit into
bitrix24:v3-devfrom
camaxtly:feature/727-crm-smart-process-read-contracts
Open

camaxtly wants to merge 1 commit into
bitrix24:v3-devfrom
camaxtly:feature/727-crm-smart-process-read-contracts

Conversation

@camaxtly

@camaxtly camaxtly commented Nov 2, 2026 •

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? yes
Deprecations? no
Issues Fix #727; Fix #728
License MIT

Smart-process exports currently need direct core calls or access to protected batch internals to discover universal CRM categories and read original custom-field names. This PR exposes typed read APIs through the existing CRM builder and preserves the request shape of existing calls.

  • Add category()->fields/get/list with typed category results and paged list access.
  • Append useOriginalUfNames=false to item fields/get/list/countByFilter and batch list; true sends useOriginalUfNames=Y.
  • Require wildcard selection for original-name batch reads: the tested portal omits system id from explicit selects in that mode, preventing safe traversal. Invalid combinations fail before requesting data. Existing default-mode batch calls remain unchanged.
  • Fix type()->delete() to send the documented internal id, preserving the legacy PHP argument name for named callers. Its result now reads the response, rejects null/no-op, and surfaces API errors.
$crm = $serviceBuilder->getCRMScope();
$categories = $crm->category()->list($entityTypeId)->getCategories();
$fields = $crm->item()->fields($entityTypeId, useOriginalUfNames: true);
foreach ($crm->item()->batch->list(
    $entityTypeId,
    ['id' => 'ASC'],
    $filter,
    ['*'],
    useOriginalUfNames: true,
) as $item) {
    // Original UF_* keys are available without accessing batch internals.
}

Validation: CS fixer, Rector, PHPStan and Deptrac passed. Full unit suite: 2467 tests / 13259 assertions, with the same 11 pre-existing deprecations as baseline. Targeted live integration: 5 tests / 153 assertions, including original-name filters, 55 unique records across batch pages, limited traversal, category metadata/result annotations, real type deletion and cleanup. Temporary fixture items are deleted before their type; absence of the type is verified. Existing Rector configuration deprecation warnings remain.

No new runtime dependencies.

Closes #727
Closes #728

@camaxtly
camaxtly force-pushed the feature/727-crm-smart-process-read-contracts branch from bd3db76 to 33746b5 Compare November 2, 2026 21:28
public function delete(int $entityTypeId): DeletedItemResult
{
return new DeletedItemResult($this->core->call('crm.type.delete', ['entityTypeId' => $entityTypeId]));
return new DeletedItemResult($this->core->call('crm.type.delete', ['id' => $entityTypeId]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the existing callers before merging this change. Four cleanup calls in ItemTest.php (lines 92, 114, 159 and 179) pass $addedTypeItemResult->type()->entityTypeId. This line sends that value as the internal type id. When the two IDs differ, the operation targets the wrong record. If that ID belongs to another empty type the account can delete, cleanup can remove it while leaving its own fixture behind.

Please delete the fixture's items first, pass $addedTypeItemResult->getId() to delete(), and document which ID callers must supply, including for named arguments. Add regression coverage with distinct IDs that verifies the fixture type is gone and the other type remains. The new check for a null REST result is worth keeping.

Existing call site · REST deletion contract

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.

2 participants