Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

curtishall
Copy link
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
@@ -1364,7 +1364,7 @@ public static function getList($manufacturer)
// print_r($data);

foreach($data['records'] as $camera) {
Copy link
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
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