-
-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Describe the problem
Short description
When we try to manage a DNS zone that was not created from a DNS zone template, an error appears in the Nginx logs:
thrown in /var/www/html/poweradmin.404/lib/Domain/Service/Dns/DomainManager.php on line 468" while reading response header from upstream, client: <client_ip>, server: pdns.company.fr, request: "GET /index.php?page=edit&id=302 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.4-fpm.sock:", host: "pdns.company.fr", referrer: "https://pdns.company.fr/index.php?page=list_forward_zones" 2025/12/29 09:44:23 [error] 561248#561248: *817 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Poweradmin\Domain\Service\Dns\DomainManager::getZoneTemplate(): Return value must be of type int, null returned in /var/www/html/poweradmin.404/lib/Domain/Service/Dns/DomainManager.php:468
This error refers to the getZoneTemplate() function in the DomainManager.php file on line 468. Here is the content of the getZoneTemplate() function:
/**
* Get Zone Template ID for Zone ID
*
* @param object $db Database connection
* @param int $zone_id Zone ID
*
* @return int Zone Template ID
*/
public static function getZoneTemplate($db, int $zone_id): int
{
$stmt = $db->prepare("SELECT zone_templ_id FROM zones WHERE domain_id = :zone_id");
$stmt->execute([':zone_id' => $zone_id]);
return $stmt->fetchColumn();
}
When we run the same SQL query in the database with the DNS zone in question, we obtain the following value:
pdns=# select zone_templ_id from zones where domain_id=296;
zone_templ_id
---------------
0
(1 line)
This results in a 0, which had to be interpreted as an int by the function. The version of PHP used for Poweradmin is 8.4. After doing some research, it appears that PHP 8.4 is very strict about the return type of variables.
Environment
-
Operating system: Debian13
-
Software version:
- poweradmin=4.0.4
- pdns-backend-bind=5.0.1-1pdns.debian135.0.1-1pdns.debian13
- pdns-backend-pgsql=5.0.1-1pdns.debian13
- pdns-server=5.0.1-1pdns.debian13
- pdns-tools=5.0.1-1pdns.debian13
- php8.4-cli=8.4.16-1~deb13u1
- php8.4-common=8.4.16-1~deb13u1
- php8.4-dev=8.4.16-1~deb13u1
- php8.4-fpm=8.4.16-1~deb13u1
- php8.4-intl=8.4.16-1~deb13u1
- php8.4-mbstring=8.4.16-1~deb13u1
- php8.4-opcache=8.4.16-1~deb13u1
- php8.4-pgsql=8.4.16-1~deb13u1
- php8.4-readline=8.4.16-1~deb13u1
- php8.4-xml=8.4.16-1~deb13u1
- postgresql=17+278
- postgresql-17=17.6-0+deb13u1
- postgresql-client-17=17.6-0+deb13u1
- postgresql-client-common=278
- postgresql-common=278
- postgresql-common-dev=278
-
Software source: Debian PowerDNS repository + sources of poweradmin 4.0.4
Steps to reproduce
- Manage a DNS zone that was not created from a template via the Poweradmin web interface.
Expected behaviour
- Access to the DNS zone management page is possible.
- the value returned by the function
getZoneTemplate()is indeed an integer
Actual behaviour
- Access to the page for managing a DNS zone is not possible.
- The value returned by the
getZoneTemplate()function is null when the zone has not been created from a zone template.
Other information
To overcome this problem, I implemented the following workaround in file /var/www/html/poweradmin.404/lib/Domain/Service/Dns/DomainManager.php:
public static function getZoneTemplate($db, int $zone_id): int
{
$stmt = $db->prepare("SELECT zone_templ_id FROM zones WHERE domain_id = :zone_id");
$stmt->execute([':zone_id' => $zone_id]);
#return $stmt->fetchColumn();
#Workaround : force return int for php8.4
$result = $stmt->fetchColumn();
return (int) $result;
Steps to reproduce
Manage a DNS zone that was not created from a template via the Poweradmin web interface.
Poweradmin version
4.0.4
Database
PostgreSQL
Additional information (optional)
thrown in /var/www/html/poweradmin.404/lib/Domain/Service/Dns/DomainManager.php on line 468" while reading response header from upstream, client: <client_ip>, server: pdns.company.fr, request: "GET /index.php?page=edit&id=302 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.4-fpm.sock:", host: "pdns.company.fr", referrer: "https://pdns.company.fr/index.php?page=list_forward_zones" 2025/12/29 09:44:23 [error] 561248#561248: *817 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Poweradmin\Domain\Service\Dns\DomainManager::getZoneTemplate(): Return value must be of type int, null returned in /var/www/html/poweradmin.404/lib/Domain/Service/Dns/DomainManager.php:468