Opened 18 years ago

Closed 18 years ago

#1131 closed patch (fixed)

PHP warnings generated by mythweb (svn version 8729) on some versions of PHP on FC4

Reported by: bob@… Owned by: xris
Priority: minor Milestone: unknown
Component: mythweb Version: head
Severity: medium Keywords: PHP
Cc: Ticket locked: no


Many distros ship PHP with the error_report variable set to E_ALL. This causes a problem with later versions of PHP when they try to key into an array with a non-existent key. This causes PHP to insert a complaint into the PHP stream BEFORE the headers are sent, completely screwing things. One solution, of course would be to tell PHP not to display errors, but a better solution is to test for the key's existence before attempting to use it. I have produced a simple patch to ...mythweb/includes/init.php as follows. I have used the function array_key_exists which was introduced with PHP 4.1, so the patch as posted won't work with older versions. If compatibility with earlier versions of PHP is needed then I can supply an equivalent function with full backwards compatibility if needed.

Oh, I'm using PHP 4.3.10 which is the latest official release for Fedora Core 4.

Hope this is of some use.


PS. This is my first submission, so apologies if I did anything (everything!) wrong.

The Patch

--- includes/init.php   (revision 8729)
+++ includes/init.php   (working copy)
@@ -8,7 +8,7 @@
  * @url         $URL$
  * @date        $Date$
- * @version     $Revision$
+ * @version     $Revision: 8649 $
  * @author      $Author$
  * @license     GPL
@@ -27,11 +27,15 @@
     global $Path;
     $Path = explode('/', preg_replace('/^\/+/',   '',    // Remove leading slashes
                          preg_replace('/[\s]+/', ' ',    // Convert extra whitespace
-                             $_SERVER['PATH_INFO']       // Grab the path info from various different places.
+                             array_key_exists('PATH_INFO', $_SERVER)
+                                                         // Grab the path info from various different places.
                                 ? $_SERVER['PATH_INFO']
-                                : ($_ENV['PATH_INFO']
+                                : (array_key_exists('PATH_INFO', $_ENV)
                                     ? $_ENV['PATH_INFO']
-                                    : $_GET['PATH_INFO']
+                                    : (array_key_exists('PATH_INFO', $_GET)
+                                         ? $_GET['PATH_INFO']
+                                         : ''
+                                      )

Change History (2)

comment:1 Changed 18 years ago by xris

Most distros (including fc4) ship with error display turned OFF. If you turn it on, it should be up to you to fix the accompanying report mode.

I'll apply most of this patch, but there are probably hundreds of other places in the code where this behavior still exists, and I won't much up the rest of the code with fixes for the rest of it.

comment:2 Changed 18 years ago by xris

Resolution: fixed
Status: newclosed

(In [8759]) fix #1131

Note: See TracTickets for help on using tickets.