Skip to content

BUG: Copy-paste error in sockets_mgm/settings.inc.php causes PHP warnings and breaks MI reload #317

@antonioabajo

Description

@antonioabajo

Description

There is a copy-paste error in the settings.inc.php file for the sockets_mgm tool. The configuration array is mistakenly assigned to $config->tcp_mgm instead of $config->sockets_mgm.

Because of this, the sockets_mgm property remains undefined, causing PHP Warnings (Invalid argument supplied for foreach()) in cfg_comm.php when accessing the tool. Furthermore, because talk_to_this_assoc_id is never loaded, clicking the "Reload in Service" button fails to trigger the MI command to the OpenSIPS node.

Troubleshooting and Context

When navigating to the Sockets Management tool, Apache logs show:
PHP Notice: Undefined property: stdClass::$sockets_mgm in /var/www/html/opensips-cp/web/common/cfg_comm.php

Upon inspecting config/tools/system/sockets_mgm/settings.inc.php, the file contains:

global $table_regex;
global $config;

// BUG HERE: It says tcp_mgm instead of sockets_mgm
$config->tcp_mgm = array(
	"title0" => array(
		"type" => "title",
		"title" => "Database"
	),
// ...

Proposed Fix

The file should be updated to properly define the $config->sockets_mgm array and include the necessary MI and display parameters.

Replacing the content with the following fully resolves the PHP errors and allows the "Reload in Service" button to work correctly:

global $table_regex;
global $config;

$config->sockets_mgm = array(
    "title0" => array(
        "type" => "title",
        "title" => "General settings"
    ),
    "talk_to_this_assoc_id" => array(
        "default" => 1,
        "name"  => "Linked system",
        "options" => get_assoc_id(),
        "type"  => "dropdown",
    ),

    "title1" => array(
        "type" => "title",
        "title" => "DB settings"
    ),
    "db_config" => array(
            "default" => 0,
            "name" => "DB configuration",
            "type" => "dropdown",
            "options" => get_db_configs(),
            "tip" => "DB configuration to use for this tool"
    ),
    "custom_table" => array(
        "default" => "sockets_mgm",
        "validation_regex" => $table_regex,
        "name" => "Custom table",
        "type" => "text"
    ),

    "title2" => array(
        "type" => "title",
        "title" => "Display settings"
    ),
    "per_page" => array(
        "default" => 30,
        "name"  => "Results per page",
        "type"  => "number",
        "validation_regex" => "^[0-9]+$",
    ),
    "page_range" => array(
        "default" => 3,
        "name"  => "Results page range",
        "type"  => "number",
        "validation_regex" => "^[0-9]+$",
    ),
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions