Ticket #9317: mythweb-php-5.1+.patch

File mythweb-php-5.1+.patch, 2.8 KB (added by Jonathan Martens <jonathan@…>, 13 years ago)

Patch to maintain compatibility for PHP 5.1+

  • mythweb/includes/compat.php

     
     1<?php
     2
     3if ( !function_exists( 'get_called_class' ) ) {
     4  function get_called_class( $bt = false, $l = 1 )
     5  {
     6    if ( !$bt ) $bt = debug_backtrace();
     7    if ( !isset( $bt[$l] ) ) throw new Exception( "Cannot find called class -> stack level too deep." );
     8    if ( !isset( $bt[$l]['type'] ) ) {
     9      throw new Exception ( 'type not set' );
     10    } else switch ( $bt[$l]['type'] ) {
     11      case '::':
     12        $lines = file( $bt[$l]['file'] );
     13        $i = 0;
     14        $callerLine = '';
     15        do {
     16          $i++;
     17          $callerLine = $lines[$bt[$l]['line'] - $i] . $callerLine;
     18        } while ( stripos( $callerLine, $bt[$l]['function'] ) === false
     19);
     20        preg_match( '/([a-zA-Z0-9\_]+)::' . $bt[$l]['function'] . '/',
     21          $callerLine,
     22          $matches );
     23        if ( !isset( $matches[1] ) ) {
     24          // must be an edge case.
     25          throw new Exception ( "Could not find caller class: originating method call is obscured." );
     26        }
     27        switch ( $matches[1] ) {
     28          case 'self':
     29          case 'parent':
     30            return get_called_class( $bt, $l + 1 );
     31          default:
     32            return $matches[1];
     33        }
     34        // won't get here.
     35      case '->': switch ( $bt[$l]['function'] ) {
     36          case '__get':
     37            // edge case -> get class of calling object
     38            if ( !is_object( $bt[$l]['object'] ) ) throw new
     39              Exception ( "Edge case fail. __get called on non object.");
     40            return get_class( $bt[$l]['object'] );
     41          default: return $bt[$l]['class'];
     42        }
     43
     44      default: throw new Exception ( "Unknown backtrace method type" );
     45    }
     46  }
     47}
     48
     49?>
     50 No newline at end of file
  • mythweb/includes/init.php

     
    1616 *
    1717/**/
    1818
     19// Attempt to load for backwards compatability
     20    require_once('compat.php');
     21
    1922// Attempt to load up firephp if installed on the server
    2023    @include_once('FirePHPCore/fb.php');
    2124
  • mythweb/includes/php_version_check.php

     
    1212 * @package     MythWeb
    1313 *
    1414/**/
    15     define('PHP_MIN_VERSION', floatval(5.3));
     15    define('PHP_MIN_VERSION', floatval(5.1));
    1616
    1717// Make sure we're running a new enough version of php
    1818    if (floatval(substr(phpversion(), 0, 3)) < PHP_MIN_VERSION)