Skip to content

Bug: REPLACE INFO typo in weathermap_setting_save() — should be REPLACE INTO #203

@somethingwithproof

Description

@somethingwithproof

Summary

weathermap_setting_save() uses REPLACE INFO instead of REPLACE INTO in all three branches. This is a SQL syntax error that breaks every call site.

Location

weathermap-cacti-plugin-mgmt.php (or wherever weathermap_setting_save() is defined)

db_execute_prepared('REPLACE INFO weathermap_settings ...

Should be:

db_execute_prepared('REPLACE INTO weathermap_settings ...

Additional DRY opportunity

The three branches in the function are structurally identical, differing only in which of mapid/groupid gets set. Consolidatable to:

function weathermap_setting_save($mapid, $name, $value) {
    [$map_val, $grp_val] = $mapid > 0
        ? [$mapid, 0]
        : ($mapid < 0 ? [0, -$mapid] : [0, 0]);

    db_execute_prepared('REPLACE INTO weathermap_settings
        (mapid, groupid, optname, optvalue)
        VALUES (?, ?, ?, ?)',
        [$map_val, $grp_val, $name, $value]);
}

Bug fix and DRY cleanup in one commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions