Code Audit of 1C-Bitrix Project
Project works, but each change becomes a lottery: fix feedback form — shopping cart breaks. New developer spends a week understanding structure. Development speed drops every month. These are symptoms of accumulated technical debt, and code audit — way to measure it, document it, and plan elimination.
What's Checked in Audit
Bitrix project audit significantly differs from arbitrary PHP-app audit. Bitrix imposes its patterns — components, templates, iblocks, agents — and quality criteria tied to them.
Iblock architecture. Iblocks — central data storage in Bitrix. Typical problems:
- Using one iblock for heterogeneous entities (products and articles in one place)
- String-type properties instead of "Directory" or "Element Link" — no filtering and relations possible
- Missing composite indexes on
b_iblock_element_propertytables for frequently used filters - Storing data in
PREVIEW_TEXT/DETAIL_TEXTinstead of separate properties — loss of structure
Components and templates. Check:
- Business logic in
template.phpinstead ofresult_modifier.phpor custom component - Direct SQL queries via
$DB->Query()instead of ORM or iblock API - Unused component parameters, copy-paste between templates
- Third-party component customization via core modification (instead of
class.phpinheritance)
init.php. File /bitrix/php_interface/init.php — main project health indicator. Bad projects contain thousands of lines: event handlers, functions, classes, SQL queries — all in one file. Good projects — only autoloader include and handler registration.
Query performance. Enable $DB->ShowSQLStat = true and analyze SQL queries per page. Normal: 30-80 queries. Problem: 300+ queries from N+1 problem: calling CIBlockElement::GetList() in loop.
Audit Result
Report contains not abstract recommendations, but specific list:
| Problem | File/Module | Severity | Recommendation |
|---|---|---|---|
| SQL in component template | /bitrix/templates/main/components/.../template.php:45 |
High | Move to result_modifier.php, use CIBlockElement::GetList() |
| N+1 on property fetching | Component catalog.section (custom) |
High | Use GetNextElement() with PROPERTY_* in $arSelect |
| init.php 2000+ lines | /bitrix/php_interface/init.php |
Medium | Decompose to modules, include via autoloader |
Severity determined by performance impact, security, and support cost. Report prioritized — top items fixed first.
Tools
- phpstan / psalm — static analysis, detecting calls to non-existent methods and properties
- PHP_CodeSniffer — code standard compliance check
-
Bitrix "Performance Monitor" (
perfmon) — SQL and PHP profiling - Xdebug + Cachegrind — detailed profiling for bottleneck detection
Audit takes 2-3 business days for medium project. Output — document for planning refactoring with clear priorities and effort estimates.







