No Code Attached Yet bug
avatar seifygsm
seifygsm
19 Jul 2026

What happened?

When editing an article in the Joomla Administrator, a fatal "Division by zero" exception is thrown if a Custom Field of type "Subform" exists without any child fields.

The exception occurs in:

layouts/joomla/form/field/subform/repeatable-table.php

The layout executes:

$fields = $tmpl->getGroup('');
$th_width = 92 / count($fields);

When the Subform contains no child fields, count($fields) returns 0, causing a Division by zero exception and preventing the article edit page from loading.

Debugging confirmed:

Field ID: jform_com_fields_fyld_dwm
Fields Count: 0

The Subform returned an empty field list.

Version

5.4

Expected result

Joomla should not crash when a Subform contains no child fields.

Instead, it should either:

  • Handle the empty Subform gracefully,
  • Display a meaningful warning,
  • Or simply skip rendering the table.

A fatal "Division by zero" exception should never occur because of an empty Subform configuration.

Actual result

The Administrator article edit page crashes with:

Division by zero

Call Stack:

JROOT/layouts/joomla/form/field/subform/repeatable-table.php

The page cannot be opened until the empty Subform Custom Field is deleted.

System Information

Joomla Version: 5.4.7

PHP Version: 8.3

Database: MySQL / MariaDB

Web Server: Apache

The issue occurs in the Administrator while editing com_content articles.

The problem disappears immediately after deleting the empty Subform Custom Field.

Additional Comments

A fatal error should never occur because of an invalid or empty Subform configuration.

Although an empty Subform configuration may be considered invalid, Joomla should validate this condition before calculating the table column width.

A simple guard before the following line would prevent the fatal exception:

$th_width = 92 / count($fields);

For example:

$fields = $tmpl->getGroup('');

if (empty($fields)) {
return;
}

or any equivalent validation that prevents division by zero.

avatar seifygsm seifygsm - open - 19 Jul 2026
avatar seifygsm seifygsm - change - 19 Jul 2026
Labels Added: bug
avatar seifygsm seifygsm - labeled - 19 Jul 2026
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2026
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Jul 2026
avatar chmst
chmst - comment - 25 Jul 2026

Confirmed. Would you like to make a PR yourself?

avatar chmst
chmst - comment - 25 Jul 2026

Confirmed.
@seifygsm Would you like to make a PR yourself? If not, please comment here, then I can do it.

avatar QuyTon QuyTon - change - 27 Jul 2026
Status New Closed
Closed_Date 0000-00-00 00:00:00 2026-07-27 02:51:36
Closed_By QuyTon
avatar QuyTon QuyTon - close - 27 Jul 2026
avatar QuyTon
QuyTon - comment - 27 Jul 2026

Please test PR #48146. Thanks.

Add a Comment

Login with GitHub to post a comment