Skip to content

Remove unneeded ID number, we just need the manufacturer name for mysql inserts#648

Open
curtishall wants to merge 1 commit intomasterfrom
issue-647
Open

Remove unneeded ID number, we just need the manufacturer name for mysql inserts#648
curtishall wants to merge 1 commit intomasterfrom
issue-647

Conversation

@curtishall
Copy link
Copy Markdown
Member

Remove unneeded ID number, we just need the manufacturer name

Fixes #647

We were pulling the following json via API...however were added the Manufactuer AND the ID (for unknown reasons) which was being inserted into the database like 'IP Camera - recpSlTQIiaJez87D' which should never have happened and the model insert into mysql was too long anyway causing an ajax error.

{
	"id": "recpSlTQIiaJez87D",
	"createdTime": "2017-08-12T02:06:43.000Z",
	"fields": {
		"ManufacturerLink": [
			"recpeE5rOIW7SRmsC"
		],
		"id": 967,
		"JPEG path": "cgi-bin/guest/Video.cgi?media=JPEG",
		"Model": "Default",
		"Manufacturer": [
			"IP Camera"
		],
		"RTSP path fixed": "/"
	}
}

Remove unneeded ID number, we just need the manufacturer name
@curtishall curtishall changed the title Update lib.php Remove unneeded ID number, we just need the manufacturer name for mysql inserts Jan 4, 2024
Comment thread www/lib/lib.php
@@ -1364,7 +1364,7 @@ public static function getList($manufacturer)
// print_r($data);

foreach($data['records'] as $camera) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This loop iterates over all known camera models for the searched manufacturer.
We can't use rawurlencode($manufacturer) as the array index because all the entries but the last one will be overwritten.

@andrey-utkin
Copy link
Copy Markdown
Contributor

I have doubt that the fix proposed is going to work. I'd need some more time to understand how the key strings of $list generated there end up in $data[model] being inserted.

Devices.model DB field is limited to 30 characters (see misc/sql/schema_mysql.sql), I think we should give it more:

CREATE TABLE `Devices` (
...
  `model` varchar(30) DEFAULT NULL,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to add IP camera using make 'IP Camera' and model 'Default

2 participants