Skip to content

Conversation

@Monviech
Copy link
Member

No description provided.

@Monviech Monviech requested a review from fichtner November 24, 2025 09:56
@Monviech Monviech self-assigned this Nov 24, 2025
@Monviech Monviech added the cleanup Low impact changes label Nov 24, 2025
$config = [];
$lexpireFields = iterator_to_array($this->lexpire->iterateItems());
foreach ($lexpireFields as $fieldName => $fieldValue) {
$value = $fieldValue->__toString();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unused.


public function isEnabled()
{
return (string)$this->general->enabled == '1' && !empty((string)(string)$this->general->interfaces);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's a (string)(string) :)

Copy link
Member

@fichtner fichtner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok with this but such refactors through the whole file should be taken with a grain of salt (risk for regressions)

I try (and sometimes fail) to avoid them when I'm not directly working on the code path.

@Monviech
Copy link
Member Author

I'll thoroughly test this before merging, it's not in any rush.

I touched these files to improve consistency since thats something I noticed in this PR: #9401

'library' => '/usr/local/lib/kea/hooks/libdhcp_lease_cmds.so'
];
if (!empty((string)$this->ha->enabled)) {
if (!$this->ha->enabled->isEmpty()) {
Copy link

@ruifung ruifung Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity (and for my open PR) is there a specific case where you'd want to use !(field->isEmpty()) vs field->isEqual('1') when checking if a boolean field is checked?

Because I've seen both being used and it's mildly confusing as to which is the preferred method for checking if a checkbox is checked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isEqual is a newer than isEmpty. isEqual(‘1’) or isEqual(1) is always safe, but isEqual(‘0’) had some issues in the past but is now always safe too. Though for booleans the best check to support perhaps would be isOn() and isOff() but that requires more brain smarts as it doesn’t really fit the base field. Just a tangent here since you asked 😊

@Monviech
Copy link
Member Author

Since I tested the before and after via these tests: #9455

I can say with some certainty that they will not cause huge regressions in config generation and other vital parts.

@Monviech Monviech merged commit 821ca86 into master Nov 26, 2025
@Monviech Monviech deleted the kea-base-methods branch November 26, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Low impact changes

Development

Successfully merging this pull request may close these issues.

4 participants