MythTV/mythweb

RFE: Display people in priority order when displaying program details

Opened this issue · 0 comments

In a follow up to #40 and #71, here is a code fragment that is mysql/mariadb complaint (test on all known/current supported mysql/mariadb versions without requiring sql_mode overrides).

Given that mythweb has a very short future lifetime, it is not clear if this a worthwhile patch, but it is now available if needed....

As I am about to delete my mythweb fork, and that means a PR would get auto deleted, this is inline.

diff --git a/modules/tv/classes/Program.php b/modules/tv/classes/Program.php
index d84a3d9f..a5d4ca77 100644
--- a/modules/tv/classes/Program.php
+++ b/modules/tv/classes/Program.php
@@ -556,9 +556,10 @@ class Program extends MythBase {
     public function has_credits() {
         global $db;
         return $db->query_col('SELECT COUNT(people.name)
-                                 FROM credits, people
-                                WHERE credits.person    = people.person
-                                  AND credits.chanid    = ?
+                                 FROM credits
+                            LEFT JOIN people
+                                   ON credits.person    = people.person
+                                WHERE credits.chanid    = ?
                                   AND credits.starttime = FROM_UNIXTIME(?)',
                               $this->chanid,
                               $this->starttime
@@ -573,13 +574,17 @@ class Program extends MythBase {
     // No cached value -- load it
         if (!isset($this->credits[$role][$add_search_links])) {
         // Get the credits for the requested role
-            $result = $db->query('SELECT DISTINCT people.name
-                                     FROM credits, people
-                                    WHERE credits.person    = people.person
-                                      AND credits.role      = ?
-                                      AND credits.chanid    = ?
-                                      AND credits.starttime = FROM_UNIXTIME(?)
-                                      ORDER BY credits.priority',
+            $result = $db->query('SELECT p.name
+                                    FROM (
+                                              SELECT DISTINCT people.name, credits.priority
+                                                FROM credits
+                                           LEFT JOIN people
+                                                  ON credits.person    = people.person
+                                               WHERE credits.role      = ?
+                                                 AND credits.chanid    = ?
+                                                 AND credits.starttime = FROM_UNIXTIME(?)
+                                            ORDER BY credits.priority
+                                         ) p',
                                    $role,
                                    $this->chanid,
                                    $this->starttime