Opened 13 years ago

Closed 13 years ago

#2040 closed patch (fixed)

Fix corrupted category in videometadata

Reported by: sphery <mtdean@…> Owned by: Anduin Withers
Priority: minor Milestone: 0.20
Component: mythvideo Version:
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Trivial patch initializes the categoryID in MythVideo's Metadata. Without the patch, using the Edit Metadata screen often results in placement of invalid ID's in the category field of the metadata table--even where a valid value previously existed (due to the use of the copy constructor in EditMetadataDialog?'s constructor, which is required to allow abandoning of changes). Since the Metadata's getCategoryID() function only calls lookupCategoryID() if categoryID <= 0, it often fails to lookup a categoryID even when we have a valid category name (depending on the uninitialized value of categoryID). In this case, the UI shows the value "Unknown", but a value equal to the uninitialized value of categoryID will be written to the database if the user saves the data. It's also theoretically possible that the uninitialized value may be a valid ID for a category, which will result in changing the user's category to something other than Unknown.

This also fixes the problem noted on the lists that categories are often made invalid by doing IMDB lookups ( http://www.gossamer-threads.com/lists/mythtv/users/190838#190838 ) (I know. I'm about a month and a half late on the fix :).

I set the categoryID to 0 in the copy constructor even though it's probably valid in the original object. Doing so allows for changes to the table "behind the scenes." This seems to be the approach that was desired by the original author (since the copy constructor did not previously copy the categoryID field) and only results in one extra query to the database per copied Metadata object. Copying the original object's categoryID should work, as well.

Also attached is a patch that "fixes" the invalid category ID's ( mythplugins-mythvideo-initialize_categoryid-dbcheck.patch ) in the database. It does this by simply changing invalid category ID's to 0, which results in the user seeing the value "Unknown" for the category (which they would see even with the invalid value). Although the dbcheck.cpp patch is not absolutely required, I feel it's prudent to remove invalid data from the database. The patch uses a LEFT JOIN instead of a subquery, so it should work on all supported versions of MySQL.

For those applying this patch to working copies, I recommend not applying the mythplugins-mythvideo-initialize_categoryid-dbcheck.patch patch and--if concerned about the invalid data--instead running the SQL below. Then, if the dbcheck patch is applied to the main distro, it will result in no changes to the metadata (since your data will be valid), but will allow you to maintain a VideoDBSchemaVer that's in sync with head (in case the patch isn't applied).

UPDATE videometadata 
LEFT JOIN videocategory ON (videometadata.category = videocategory.intid)
SET videometadata.category = 0
WHERE videocategory.intid IS NULL;

Attachments (2)

mythplugins-mythvideo-initialize_categoryid.patch (792 bytes) - added by sphery <mtdean@…> 13 years ago.
Main patch (fixes unitialized categoryID)
mythplugins-mythvideo-initialize_categoryid-dbcheck.patch (862 bytes) - added by sphery <mtdean@…> 13 years ago.
Patch to "fix" invalid category ID's in the metadata table

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by sphery <mtdean@…>

Main patch (fixes unitialized categoryID)

Changed 13 years ago by sphery <mtdean@…>

Patch to "fix" invalid category ID's in the metadata table

comment:1 Changed 13 years ago by Anduin Withers

Milestone: 0.20

comment:2 Changed 13 years ago by sphery <mtdean@…>

Summary: Initialize categoryID in MetadataFix corrupted category in videometadata

Confirming that mythplugins-mythvideo-initialize_categoryid.patch is obsoleted by #2159 (the issue is fixed in that patch), so all that remains is to fix invalid category ID's in the users' databases ( mythplugins-mythvideo-initialize_categoryid-dbcheck.patch ).

comment:3 Changed 13 years ago by Anduin Withers

Resolution: fixed
Status: newclosed

(In [10852]) Closes #2197, #1647, #1746, #679, #1569, #1678, #2040, #2159, #2167, #2170

Various small cleanups and speed improvements.

  • Folders in metadata only view
  • Option to ignore case in title comparisons (though a locale may override this)
  • Multiple prefixes should be consistent now
  • All metadata fields are available to the theme in all views
  • Minor redraw issue
  • Consistent metadata representation across views (where appropriate)

Fixes fully (to my knowledge) all referenced tickets.

Note: See TracTickets for help on using tickets.