class SqlConsistencyChecks extends AbstractConsistencyChecks (View source)

Consistency checks against the PowerDNS tables in the local database.

Methods

__construct(PDO $db, TableNameService $tableNameService, ZoneOwnerRepair $ownerRepair, DefaultSoaBuilder $defaultSoa, AccountOwnerLookup|null $accountOwners = null, ZoneChangeRequestRepositoryInterface|null $changeRequests = null, LoggerInterface $logger = new NullLogger())

No description

bool
fixZoneWithoutOwner(int $zoneId, int $currentUserId)

Assign $currentUserId as the owner of a zone that has none.

string|null
zoneAccount(int $zoneId)

The zone's PowerDNS account, or null where this backend does not read it.

array
fixAllZonesWithoutOwner(int $currentUserId)

No description

array
fixOne(string $type, int $id, int $currentUserId)

Apply the single-item repair for a consistency page check type (zones_without_owners, zones_without_canonical_ids, records_with_uppercase_names, slave_zones_without_masters, orphaned_records, duplicate_soa, zones_without_soa) to one finding.

array
fixAll(string $type, int $currentUserId)

Apply a check type's bulk repair to every finding; only the two zone checks offer one.

array
groupByLowerName(array $zones)

One finding per zone name used by more than one zone in different letter case.

array
checkZonesHaveOwners()

No description

array
checkZonesHaveCanonicalIds()

SQL mode stores a domains foreign key in zones.domain_id, where the row's own id is not a valid substitute, so there is nothing this check may safely report or repair.

array
checkZonesHaveNames()

Zones with owners or grants but no zones row carrying their exact name, which a switch to the API backend would add again without them. Only the SQL backend can have them.

array
checkSharedZoneIds()

SQL mode keys every zone by its unique domains.id, so no id can be shared.

array
checkGroupGrantsOnRowIds()

SQL mode keys zones by domains.id only, so no group assignment holds a row id.

array
checkApiKeyScopesNameZones()

API key zone restrictions naming a zone id no zone has, which a zone later given that id would fall under. Only the SQL backend hands out an id again.

array
checkZoneNamesDifferingInCase()

Zone names that exist more than once in different letter case, such as Example.com and example.com, which PowerDNS treats as the same name. Report only.

array
checkRecordNamesInLowercase()

Records whose name holds uppercase letters, which PowerDNS never serves and the record lookups never find. Only the SQL backend can store them.

array
checkSlaveZonesHaveMasters()

No description

array
checkRecordsBelongToZones()

No description

array
checkDuplicateSOARecords()

No description

array
checkZonesWithoutSOA()

No description

array|null
runAllChecks()

Run every check, keyed by check name. Null means the backend could not be read and no result can be trusted.

bool
fixZoneCanonicalId(int $zoneId)

Point a stranded zones row's domain_id at its own id; $zoneId is the row's primary key.

array
bool
fixApiKeyScopesOnMissingZone(int $zoneId)

Point the API key restrictions on $zoneId, which no zone has, at no zone.

array
bool
fixZoneName(int $zoneId)

Give the zone a zones row carrying its PowerDNS name; $zoneId is the domains.id.

array
fixAllZonesWithoutName()

No description

bool
fixRecordNameCase(int $recordId)

Renames the record to its lowercase name. When that name already holds the same record the mixed-case copy is deleted instead. A rename that would leave two versions of one record, or a CNAME next to other data, is refused.

array
fixAllRecordNamesCase()

No description

bool
deleteSlaveZone(int $zoneId)

No description

bool
deleteOrphanedRecord(int $recordId)

No description

bool
fixDuplicateSOA(int $zoneId)

Keep the first SOA record of the zone and delete the rest.

bool
createDefaultSOA(int $zoneId)

No description

Details

__construct(PDO $db, TableNameService $tableNameService, ZoneOwnerRepair $ownerRepair, DefaultSoaBuilder $defaultSoa, AccountOwnerLookup|null $accountOwners = null, ZoneChangeRequestRepositoryInterface|null $changeRequests = null, LoggerInterface $logger = new NullLogger())

No description

Parameters

PDO $db
TableNameService $tableNameService
ZoneOwnerRepair $ownerRepair
DefaultSoaBuilder $defaultSoa
AccountOwnerLookup|null $accountOwners

Prefers the user a zone's PowerDNS account names (dns.adopt_zone_owner_from_account)

ZoneChangeRequestRepositoryInterface|null $changeRequests

Cancels the open change requests of a deleted slave zone

LoggerInterface $logger

bool fixZoneWithoutOwner(int $zoneId, int $currentUserId)

Assign $currentUserId as the owner of a zone that has none.

Parameters

int $zoneId
int $currentUserId

Return Value

bool

protected string|null zoneAccount(int $zoneId)

The zone's PowerDNS account, or null where this backend does not read it.

Parameters

int $zoneId

Return Value

string|null

array fixAllZonesWithoutOwner(int $currentUserId)

No description

Parameters

int $currentUserId

Return Value

array

array fixOne(string $type, int $id, int $currentUserId)

Apply the single-item repair for a consistency page check type (zones_without_owners, zones_without_canonical_ids, records_with_uppercase_names, slave_zones_without_masters, orphaned_records, duplicate_soa, zones_without_soa) to one finding.

Parameters

string $type
int $id
int $currentUserId

Return Value

array

status is success or error

array fixAll(string $type, int $currentUserId)

Apply a check type's bulk repair to every finding; only the two zone checks offer one.

Parameters

string $type
int $currentUserId

Return Value

array

status is success, warning or error

protected array groupByLowerName(array $zones)

One finding per zone name used by more than one zone in different letter case.

Parameters

array $zones

Return Value

array

array checkZonesHaveOwners()

No description

Return Value

array

array checkZonesHaveCanonicalIds()

SQL mode stores a domains foreign key in zones.domain_id, where the row's own id is not a valid substitute, so there is nothing this check may safely report or repair.

Return Value

array

array checkZonesHaveNames()

Zones with owners or grants but no zones row carrying their exact name, which a switch to the API backend would add again without them. Only the SQL backend can have them.

Return Value

array

array checkSharedZoneIds()

SQL mode keys every zone by its unique domains.id, so no id can be shared.

Return Value

array

array checkGroupGrantsOnRowIds()

SQL mode keys zones by domains.id only, so no group assignment holds a row id.

Return Value

array

array checkApiKeyScopesNameZones()

API key zone restrictions naming a zone id no zone has, which a zone later given that id would fall under. Only the SQL backend hands out an id again.

Return Value

array

array checkZoneNamesDifferingInCase()

Zone names that exist more than once in different letter case, such as Example.com and example.com, which PowerDNS treats as the same name. Report only.

Return Value

array

array checkRecordNamesInLowercase()

Records whose name holds uppercase letters, which PowerDNS never serves and the record lookups never find. Only the SQL backend can store them.

Return Value

array

array checkSlaveZonesHaveMasters()

No description

Return Value

array

array checkRecordsBelongToZones()

No description

Return Value

array

array checkDuplicateSOARecords()

No description

Return Value

array

array checkZonesWithoutSOA()

No description

Return Value

array

array|null runAllChecks()

Run every check, keyed by check name. Null means the backend could not be read and no result can be trusted.

Return Value

array|null

bool fixZoneCanonicalId(int $zoneId)

Point a stranded zones row's domain_id at its own id; $zoneId is the row's primary key.

Parameters

int $zoneId

Return Value

bool

array fixAllZonesWithCanonicalIdIssue()

No description

Return Value

array

bool fixApiKeyScopesOnMissingZone(int $zoneId)

Point the API key restrictions on $zoneId, which no zone has, at no zone.

Parameters

int $zoneId

Return Value

bool

array fixAllApiKeyScopesOnMissingZones()

No description

Return Value

array

bool fixZoneName(int $zoneId)

Give the zone a zones row carrying its PowerDNS name; $zoneId is the domains.id.

Parameters

int $zoneId

Return Value

bool

array fixAllZonesWithoutName()

No description

Return Value

array

bool fixRecordNameCase(int $recordId)

Renames the record to its lowercase name. When that name already holds the same record the mixed-case copy is deleted instead. A rename that would leave two versions of one record, or a CNAME next to other data, is refused.

Parameters

int $recordId

Return Value

bool

array fixAllRecordNamesCase()

No description

Return Value

array

bool deleteSlaveZone(int $zoneId)

No description

Parameters

int $zoneId

Return Value

bool

bool deleteOrphanedRecord(int $recordId)

No description

Parameters

int $recordId

Return Value

bool

bool fixDuplicateSOA(int $zoneId)

Keep the first SOA record of the zone and delete the rest.

Parameters

int $zoneId

Return Value

bool

bool createDefaultSOA(int $zoneId)

No description

Parameters

int $zoneId

Return Value

bool