From 7a0af293fd1a81fb643acbb954d319786035e44e Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 2 Nov 2012 17:20:15 -0500
Subject: mythtv:  applied mythweb and php bindings patch to allow mythweb to
 work with php 5.4

refs #861
closes #861
---
 .../mythtv/stable-0.25/mythtv/MythBase.php.patch   | 19 +++++++++++++
 abs/core/mythtv/stable-0.25/mythtv/PKGBUILD        |  4 ++-
 abs/core/mythtv/stable-0.25/mythweb/PKGBUILD       | 31 +++++++++++++--------
 .../mythtv/stable-0.25/mythweb/mythweb.include     |  8 ++++++
 .../mythtv/stable-0.25/mythweb/mythweb.install     | 32 ++++++++++++++++++++++
 .../mythtv/stable-0.25/mythweb/mythweb.php.patch   | 11 --------
 .../mythtv/stable-0.25/mythweb/schedules.php.patch | 16 +++++++++++
 .../mythtv/stable-0.25/mythweb/sorting.php.patch   | 19 +++++++++++++
 .../stable-0.25/mythweb/tv-schedules.php.patch     | 15 ++++++++++
 9 files changed, 132 insertions(+), 23 deletions(-)
 create mode 100644 abs/core/mythtv/stable-0.25/mythtv/MythBase.php.patch
 create mode 100644 abs/core/mythtv/stable-0.25/mythweb/mythweb.include
 create mode 100644 abs/core/mythtv/stable-0.25/mythweb/mythweb.install
 delete mode 100644 abs/core/mythtv/stable-0.25/mythweb/mythweb.php.patch
 create mode 100644 abs/core/mythtv/stable-0.25/mythweb/schedules.php.patch
 create mode 100644 abs/core/mythtv/stable-0.25/mythweb/sorting.php.patch
 create mode 100644 abs/core/mythtv/stable-0.25/mythweb/tv-schedules.php.patch

diff --git a/abs/core/mythtv/stable-0.25/mythtv/MythBase.php.patch b/abs/core/mythtv/stable-0.25/mythtv/MythBase.php.patch
new file mode 100644
index 0000000..ff1f4b6
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythtv/MythBase.php.patch
@@ -0,0 +1,19 @@
+*** a/mythtv/bindings/php/MythBase.php.old	2011-04-03 06:05:31.000000000 -0500
+--- b/mythtv/bindings/php/MythBase.php	2012-03-27 05:05:16.000000000 -0500
+***************
+*** 51,57 ****
+  
+      public function __destruct() {
+          if (!is_null($this->cacheKey))
+!             Cache::setObject($this->cacheKey, &$this, $this->cacheLifetime);
+          $this->cacheKey = null;
+      }
+  
+--- 51,57 ----
+  
+      public function __destruct() {
+          if (!is_null($this->cacheKey))
+!             Cache::setObject($this->cacheKey, $this, $this->cacheLifetime);
+          $this->cacheKey = null;
+      }
+  
diff --git a/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD b/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
index 50f24c1..63f8b90 100644
--- a/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
+++ b/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
@@ -61,7 +61,8 @@ groups=('pvr')
 #options=(!strip)
 #MAKEFLAGS="-j6"
 install='mythtv.install'
-patchs=('myth_settings.patch')
+#http://code.mythtv.org/trac/ticket/10504
+patchs=('myth_settings.patch' MythBase.php.patch )
 optdepends=('xmltv: to download tv listings')
 replaces=('mythvideo' 'myththemes')
 conflicts=('mythvideo' 'myththemes')
@@ -143,6 +144,7 @@ package() {
 md5sums=('7ef6de58240e7aad389a0b13d91b1cf6'
          '2babd4b8e146a7538d18dcd55695b0be'
          '322f48528b350f0e6aebfff6eab4c4ee'
+         '9ec33d6956464283636c1f9a781dd4fd'
          'f735805a80b0d1180dee01f9df1b7004'
          'f407d6af23e74a49540755420f84fa58'
          '5469d9921b726db750b991c87d226158')
diff --git a/abs/core/mythtv/stable-0.25/mythweb/PKGBUILD b/abs/core/mythtv/stable-0.25/mythweb/PKGBUILD
index 6ec3453..7c0cc8d 100644
--- a/abs/core/mythtv/stable-0.25/mythweb/PKGBUILD
+++ b/abs/core/mythtv/stable-0.25/mythweb/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythweb
 pkgver=0.25
-pkgrel=3
+pkgrel=5
 
 commit_hash=`cat ../git_src/git_hash_web`
 
@@ -11,25 +11,26 @@ arch=('i686' 'x86_64')
 
 depends=('mythtv>=0.25' 'lighttpd' 'php' 'local-website')
 groups=('mythtv-extras')
+install=mythweb.install
+#http://code.mythtv.org/trac/ticket/10504
+patches=(schedules.php.patch  sorting.php.patch  tv-schedules.php.patch)
+source=(`echo ${patches[@]:0}` mythweb.include)
 
-patches=()
-source=(`echo ${patches[@]:0}`)
-
-DOCROOT=/data/srv/httpd/htdocs/mythweb
+DOCROOT=/data/srv/httpd/mythweb
 build() {
 
    if [ -e ${srcdir}/mythweb ]
       then
           rm -rf ${srcdir}/mythweb
       fi
-  
+
       cd ${startdir}
       msg "copy in myth web src"
       cp -rp ../git_src/mythweb $srcdir
       cd ${srcdir}/${pkgbase}
-  
-  
-  
+
+
+
     msg "The local files are updated."
 
 
@@ -45,7 +46,7 @@ build() {
 		patch -Np0  -i ${srcdir}/$i  || return 1
 	done
 	echo "--------------------------done applying patches-----------------------------------------------"
-	
+
 	[ "$CARCH" = "i686"   ] && ARCH="i686"
 	[ "$CARCH" = "x86_64" ] && ARCH="x86-64"
 
@@ -59,5 +60,13 @@ build() {
         # http://code.mythtv.org/trac/ticket/9255
         cd ${pkgdir}/${DOCROOT}
         ln -s modules modules_path
+
+    #install conf files for lighttpd
+    mkdir -p $pkgdir/etc/lighttpd
+    install -D -m 644 $srcdir/mythweb.include          $pkgdir/etc/lighttpd/
+
 }
-md5sums=('45703fa3899c4ee84d1b087bfcc6654e')
+md5sums=('392e570594859c026ac12194920246d8'
+         '53cc59d6a8bf144027b25d5dcbfffc66'
+         '515e29fda503c199888a91553e1815a0'
+         '7645a6399434cbba35639713ac5d88e0')
diff --git a/abs/core/mythtv/stable-0.25/mythweb/mythweb.include b/abs/core/mythtv/stable-0.25/mythweb/mythweb.include
new file mode 100644
index 0000000..18e9be1
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythweb/mythweb.include
@@ -0,0 +1,8 @@
+alias.url += ( "/mythweb" => "/data/srv/httpd/mythweb/")
+
+url.rewrite-once = (
+"^/{1,2}mythweb/(css|data|images|js|themes|skins|[a-z_]+\.(php|pl)).*" => "$0",
+"^/{1,2}mythweb/(pl(/.*)?)$" => "/mythweb/mythweb.pl/$1",
+"^/{1,2}mythweb/(.+)$"       => "/mythweb/mythweb.php/$1",
+"^/{1,2}mythweb/(.*)$"       => "/mythweb/mythweb.php"
+)
\ No newline at end of file
diff --git a/abs/core/mythtv/stable-0.25/mythweb/mythweb.install b/abs/core/mythtv/stable-0.25/mythweb/mythweb.install
new file mode 100644
index 0000000..f5abcea
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythweb/mythweb.install
@@ -0,0 +1,32 @@
+post_install() {
+ COUNT=`grep -c "mythweb.include" /etc/lighttpd/conf.include`
+ if [ $COUNT == 0 ]
+ then
+    echo "==> Adding mythweb.include to conf.include"
+    echo "include \"/etc/lighttpd/mythweb.include\""  >>  /etc/lighttpd/conf.include
+ fi
+ echo
+ echo "==> Forcing a re-read of lighttpd's configuration file."
+ echo ""
+  /sbin/sv hup /service/lighttpd
+}
+post_upgrade() {
+  post_install
+
+}
+
+post_remove() {
+ COUNT=`grep -c "mythweb.include" /etc/lighttpd/conf.include`
+ if [ $COUNT -gt 0 ]
+ then
+      echo "==> Removing mythweb.include from conf.include"
+      sed -i 's#include \"/etc/lighttpd/mythweb.include\"##' -i  /etc/lighttpd/conf.include
+ fi
+
+ echo
+ echo "==> Forcing a re-read of lighttpd's configuration file."
+ echo ""
+  /sbin/sv hup /service/lighttpd
+#--
+
+}
diff --git a/abs/core/mythtv/stable-0.25/mythweb/mythweb.php.patch b/abs/core/mythtv/stable-0.25/mythweb/mythweb.php.patch
deleted file mode 100644
index 4525e68..0000000
--- a/abs/core/mythtv/stable-0.25/mythweb/mythweb.php.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mythweb.php.orig	2011-02-01 03:33:56.000000000 +0000
-+++ mythweb.php	2011-02-01 03:34:20.000000000 +0000
-@@ -30,7 +30,7 @@
-     if (Modules::getModule($Path[0])) {
-     // Add the current module directory to our search path, so modules can
-     // define includes, etc.
--        ini_set('include_path', ini_get('include_path').':'.modules_path.'/'.$Path[0]);
-+        ini_set('include_path', ini_get('include_path').':'.modules.'/'.$Path[0]);
-     // Load the module handler
-         require_once 'handler.php';
-     }
diff --git a/abs/core/mythtv/stable-0.25/mythweb/schedules.php.patch b/abs/core/mythtv/stable-0.25/mythweb/schedules.php.patch
new file mode 100644
index 0000000..1d41711
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythweb/schedules.php.patch
@@ -0,0 +1,16 @@
+*** modules/tv/tmpl/default/schedules.php.old	2011-04-03 06:05:31.000000000 -0500
+--- modules/tv/tmpl/default/schedules.php	2012-03-27 05:37:40.000000000 -0500
+***************
+*** 90,95 ****
+--- 90,100 ----
+  </tr>
+  </thead>
+  <?php
++         // Hack:  Disable warnings about "Creating default
++         // object from empty value" from below line
++         // "$schedule->channel->name = '[ '.t('Any').' ]';"
++         ini_set('error_reporting', E_ERROR);
++ 
+          $prev_group = '';
+          $cur_group  = '';
+          foreach ($the_schedules as $schedule) {
diff --git a/abs/core/mythtv/stable-0.25/mythweb/sorting.php.patch b/abs/core/mythtv/stable-0.25/mythweb/sorting.php.patch
new file mode 100644
index 0000000..2f76216
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythweb/sorting.php.patch
@@ -0,0 +1,19 @@
+*** includes/sorting.php.old	2011-04-03 06:05:31.000000000 -0500
+--- includes/sorting.php	2012-03-27 05:05:51.000000000 -0500
+***************
+*** 123,129 ****
+      function by_user_choice(&$a, &$b) {
+          foreach ($GLOBALS['user_sort_choice'] as $sort) {
+              $function = 'by_'.$sort['field'];
+!             $response = $function(&$a, &$b);
+          // Identical response, go on to the next sort choice
+              if (!$response)
+                  continue;
+--- 123,129 ----
+      function by_user_choice(&$a, &$b) {
+          foreach ($GLOBALS['user_sort_choice'] as $sort) {
+              $function = 'by_'.$sort['field'];
+!             $response = $function($a, $b);
+          // Identical response, go on to the next sort choice
+              if (!$response)
+                  continue;
diff --git a/abs/core/mythtv/stable-0.25/mythweb/tv-schedules.php.patch b/abs/core/mythtv/stable-0.25/mythweb/tv-schedules.php.patch
new file mode 100644
index 0000000..29e4ccb
--- /dev/null
+++ b/abs/core/mythtv/stable-0.25/mythweb/tv-schedules.php.patch
@@ -0,0 +1,15 @@
+*** modules/tv/schedules.php.orig	2012-06-05 09:05:32.935946957 +0200
+--- modules/tv/schedules.php	2012-06-05 09:05:36.633022229 +0200
+***************
+*** 47,52 ****
+--- 47,56 ----
+      if (count($the_schedules))
+          sort_programs($the_schedules, 'schedules_sortby');
+  
++ 			  // Hack:  Disable warnings about "Creating default
++ 			  // object from empty value" from below line
++ 			  // "$schedule->channel->name = '[ '.t('Any').' ]';"
++ 			  ini_set('error_reporting', E_ERROR);
+  // Load the class for this page
+      require_once tmpl_dir.'schedules.php';
+  
-- 
cgit v0.12

