Skip to main content

Rentiva v4.37.3 — CI lint hotfix

· 2 min read
MaxHandMade
Maintainer

A short patch to clear the CI red mark left behind by v4.37.2. A single WPCS sniff — "Opening PHP tag must be on a line by itself" — failed on the v4.37.2 hero template after merge. v4.37.3 refactors the block so the PHP opening tag stands alone. Lint-only — no behaviour change.

What broke

v4.37.2 introduced a dual-escape branch for the avatar <img src> that handles the new SVG data URI fallback (esc_attr() for our own SVG payload, esc_url() for everything else). The branch was written compactly:

<?php if (!empty($data['avatar_url'])) :
// 7 lines of comments and variable assignments
$mhm_avatar_url = (string) $data['avatar_url'];
$mhm_is_inline_svg = strpos($mhm_avatar_url, 'data:image/svg+xml') === 0;
?>
<img src="<?php echo $mhm_is_inline_svg ? esc_attr(...) : esc_url(...); ?>" />
<?php endif; ?>

WPCS Generic.PHP.LowerCaseKeyword's companion sniff treats line 19 — <?php if (...) : followed by multi-statement body — as a violation. The PHP opening tag should be alone on its line when the block runs across multiple statements.

Why it slipped through release prep

The release script we use before ZIP packaging is composer phpcs:release, which is scoped to release files only:

phpcs:release: phpcs --standard=phpcs.xml \
mhm-rentiva.php uninstall.php src templates assets/blocks

CI runs composer phpcs (no :release), which is the full project including tests/, with broader rules enabled. The hero template was in both scopes, but the sniff that triggered it only fires in the broader CI configuration.

Lesson going to KB: future release PRs need to run the broader composer phpcs before merging, not just phpcs:release. The two are not interchangeable.

The fix

<?php
// (8 lines of comments)
$mhm_avatar_url = (string) ( $data['avatar_url'] ?? '' );
$mhm_is_inline_svg = strpos($mhm_avatar_url, 'data:image/svg+xml') === 0;
?>
<?php if ($mhm_avatar_url !== '') : ?>
<img src="..." />
<?php endif; ?>

<?php opens its own line. Variable assignments are a separate block. The conditional is single-line. Same shape as the rest of the hero partial (Member %s block, badge branch).

Should you update?

If you're running v4.37.2 in production: no, this update is not necessary. The runtime is identical. v4.37.3 exists so the CI badge on the repo stays green and the testing.yml workflow remains a reliable gate.

Tests

  • PHPUnit: 1007 / 3208 / 7 skipped — unchanged from v4.37.2
  • PHPCS: 0 errors (full project)