PHP downgrade

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

PHP downgrade

Postby Innocentus » 31. January 2009 10:18

Da ich den xampp-Server als Entwicklungsserver nutze,
sollte die PHP-Version der PHP-Version des Produktionsserver entsprechen.
Auf das System des Produktionsservers habe ich keinen Zugriff - ein Update ist also nicht möglich.

Der Produktionsserver verwendet die PHP-Version 5.1.6-1
- diese hat einen speziellen Bug, der in besonderen Fällen auftritt:
( http://www.phpbar.de/w/toString() )
http://www.phpbar.de/w/toString() wrote:Bei String-Verknüpfungen mit dem Vereinigungs-Operator (.) wird die __toString()-Methode in PHP Versionen < 5.2 nicht aufgerufen.


Ich muss also das PHP des aktuellen xampp-Servers auf PHP Version 5.1.6-1 downgraden.
Habt ihr da eine Anleitung o. ä.?

EDIT: Besser noch wäre eine Art Switch wie bei dem PHP-Switch,
mit dem man zwischen PHP 5 und PHP 4 wechseln konnte.
Dann kann ich das Downgrade an- und wieder abschalten.
Und das wäre natürlich noch praktischer.

Vielen Dank für eure Antworten im Vorraus!
Mit freundlichen Grüßen
Innocentus
Innocentus
 
Posts: 32
Joined: 28. January 2009 14:10

Re: PHP downgrade

Postby Xardas der Dunkle » 31. January 2009 13:34

Erstmal, das mit dem __toString ist kein Bug. Vor PHP 5.2 funktionierte __toString nur in direkter Verbindung mit echo und print. Auch ein cast nach (string) funktionierte nicht.
Es ist, aber kein Bug, sondern es wurde einfach nicht implementiert.

Dein Problem sollte erstmal, sein überhaupt die entsprechenden php5.1.6 Binarys zu finden! Auf php.net habe ich sie jetzt nicht gefunden :(.

/edit: @Wiedmann und wie kommt man dahin!?
/edit2: Ah über die sitemap, ...
Last edited by Xardas der Dunkle on 31. January 2009 14:16, edited 2 times in total.
User avatar
Xardas der Dunkle
 
Posts: 482
Joined: 09. March 2008 19:40
Location: /var/www

Re: PHP downgrade

Postby Wiedmann » 31. January 2009 14:01

Dein Problem sollte erstmal, sein überhaupt die entsprechenden php5.1.6 Binarys zu finden! Auf php.net habe ich sie jetzt nicht gefunden

http://de.php.net/releases/#5.1.6
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP downgrade

Postby Innocentus » 31. January 2009 15:52

Vielen Dank erst einmal für eure Antworten.
Die Windows-Binary habe ich jetzt heruntergeladen.

Aber wie soll ich das jetzt so in xampp installieren, dass ich später
mit einer .bat zwischen dem aktuellen- und dem downgrade-php switchen kann?

Etwas Ahnliches gibt es ja bereits zum Switchen zwischen
PHP4 und PHP5 über eine .bat in xampp.

Mit freundlichen Grüßen
Innocentus
Innocentus
 
Posts: 32
Joined: 28. January 2009 14:10

Re: PHP downgrade

Postby Innocentus » 31. January 2009 21:21

Kann mir denn vielleicht einer wenigstens sagen, wie ich an den Inhalt der php-switch.php komme?
Denn dort wird ja auch eine PHP-Installation gewechselt.
Vom Prinzip her dürfte doch nicht allzuviel anders sein, oder?

Vielen Dank für die Antworten im Vorraus!
Mit freundlichen Grüßen
Innocentus
Innocentus
 
Posts: 32
Joined: 28. January 2009 14:10

Re: PHP downgrade

Postby Wiedmann » 31. January 2009 21:30

Kann mir denn vielleicht einer wenigstens sagen, wie ich an den Inhalt der php-switch.php komme?

Naja, die ist bei jeder XAMPP Version kleiner 1.7.0 dabei...
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP downgrade

Postby Innocentus » 31. January 2009 21:32

php-switch.bat:
Code: Select all
@ECHO OFF

if exist php\php.exe GOTO Normal
if not exist php\php.exe GOTO Abort

:Abort
echo Sorry ... cannot find php cli!
echo Must abort these process!
pause
GOTO END

:Normal
set PHP_BIN=php\php.exe
set CONFIG_PHP=install\php-switch.php
%PHP_BIN% -n -d output_buffering=0 %CONFIG_PHP%
GOTO END

:END
pause



php-switch.php
Code: Select all
<?php
   /*
   #### Installer PHP  1.5  ####
   #### Author: Kay Vogelgesang & Carsten Wiedmann for www.apachefriends.org 2006 ####
   */

   echo "\r\n  ########################################################################\n";
   echo "  # ApacheFriends XAMPP PHP Switch win32 Version 1.6                     #\r\n";
   echo "  #----------------------------------------------------------------------#\r\n";
   echo "  # Copyright (c) 2002-2006 Apachefriends                                #\r\n";
   echo "  #----------------------------------------------------------------------#\r\n";
   echo "  # Authors: Kay Vogelgesang <kvo@apachefriends.org>                     #\r\n";
   echo "  #          Carsten Wiedmann <webmaster@wiedmann-online.de>             #\r\n";
   echo "  ########################################################################\r\n\r\n";

   ini_set('default_socket_timeout', '3'); // Fix by Wiedmann
   if (false !== ($handle = @fopen('http://127.0.0.1/', 'r'))) {
      fclose($handle);
      echo '   The Apache is running! Please stop the Apache before make this procedure!'."\r\n";
      echo '   Der Apache laeuft gerade! Bitte den Apache fuer diese Prozedur stoppen!'."\r\n";
      echo '   PHP Switch exit ...'."\r\n\r\n";
      exit;
   } else {
      unset($handle);

      /// Where I stand? ///
      $curdir = getcwd();
      list($partition, $nonpartition) = split (':', $curdir);
      list($partwampp, $directorwampp) = spliti ('\\\install', $curdir);
      $awkpart = eregi_replace("\\\\", "\\\\", $partwampp);
      $awkpartslash = ereg_replace("\\\\", "/", $partwampp);
      $phpdir = $partwampp;
      $dir = ereg_replace("\\\\", "/", $partwampp);
      $ppartition = "$partition:";

      /// I need the install.sys + update.sys for more xampp informations
      $phpversionfile = ".phpversion";
      $phpversionfileroot = $partwampp."\install\\".$phpversionfile;

      $phpcurrent = $partwampp."\apache\bin\php.ini";
      $php5safety = $partwampp."\php\php5.ini";
      $php4safety = $partwampp."\php\php4\php4.ini";
      $php4dir = $partwampp."\php\php4";
      $php5dir = $partwampp."\php";

      $apachebin = $partwampp."\apache\bin";
      $httpconf = $partwampp."\apache\conf\extra\httpd-xampp.conf";

      /// XAMPP main directrory is ...
      $substit = "\\\\\\\\xampp";
      $substitslash = "/xampp";

      /// Globale variables
      $BS = 0;
      $CS = 0;

      $awkexe = ".\install\awk.exe";
      $awk = ".\install\config.awk";

      $awknewdir = "\"".$awkpart."\"";
      $awkslashdir = "\"".$awkpartslash."\"";

      if (file_exists($phpversionfileroot)) {
         $datei = fopen($phpversionfileroot, 'r');
         while (!feof($datei)) {
            $phpcurrentv = fgets($datei, 255);
         }
         fclose($datei);
      } else {
         echo "   Cannot find $phpversionfileroot! So i cannot select the current PHP version.\r\n";
         echo "   Die $phpversionfileroot! Kann nicht die akuelle PHP Version bestimmen.\r\n";
         echo "   PHP Switch exit ...\r\n\r\n";
         exit;
      }

      if (($phpcurrentv != "4") && ($phpcurrentv != "5")) {
         echo "   The PHP version number is not valid.\r\n";
         echo "   Die PHP Version Nummer ist ungueltig.\r\n";
         echo "   PHP Switch exit ...\r\n\r\n";
         exit;
      }

      echo "\r\n\r\n  The working version in XAMPP is => PHP $phpcurrentv <=\r\n";
      echo "  The verwendete Version in XAMPP ist => PHP $phpcurrentv <=\r\n\r\n";

      set_time_limit(0);
      define('NEWSTDIN', fopen("php://stdin", "r"));
      while ($CS == "0") {
         echo "\r\n  Type number or 'x' (exit) for selecting your choice!\r\n";
         echo "  Gebe nun Nummer oder 'x' (exit) zum auswaehlen ein!\r\n\r\n";
         if ($phpcurrentv == "5") {
            echo "  4) Switching to PHP 4 (zu PHP 4 wechseln)\r\n";
         } elseif ($phpcurrentv == "4") {
            echo "  5) Switching to PHP 5 (zu PHP 5 wechseln)\r\n";
         } else {
            echo "  5) Switching to PHP 5 (zu PHP 5 wechseln)\r\n";
            echo "  4) Switching to PHP 4 (zu PHP 4 wechseln)\r\n";
         }
         echo "  x) Exit (Beenden)\r\n";

         switch (trim(fgets(NEWSTDIN, 256))) {
            case 4:
               $CS = 4;
               echo "\r\n  Starting configure XAMPP with PHP 4 ...\r\n\r\n";
               sleep(1);
               break;

            case 5:
               $CS = 5;
               echo "\r\n  Starting configure XAMPP with PHP 5 ...\r\n\r\n";
               sleep(1);
               break;

            case "x":
               echo "\r\n  PHP Switch is terminating on demand ...  exit\r\n";
               echo "  PHP Switch wurde auf Wunsch abgebrochen ...\r\n\r\n";
               sleep(3);
               exit;

            default:
               exit;
         }
      }
      fclose(NEWSTDIN);

      if (($CS == "4") && ($phpcurrentv=="5")) {
         echo "  Installing PHP4 in XAMPP now!\r\n\r\n";
         sleep(1);

         if (file_exists($phpcurrent)) {
            echo "  Copy the current php.ini to $php5safety ... ";
            copy($phpcurrent, $php5safety);
            echo "done!\r\n";
         }

         if (file_exists($php4safety)) {
            echo "  Copy the php4.ini to $phpcurrent ... ";
            copy($php4safety, $phpcurrent);
            echo "done!\r\n\r\n";
         }

         if (file_exists($httpconf)) { // Fix by Wiedmann
            echo '  Change PHP settings in '.$httpconf.' ... ';
            $httpconfcontent = file_get_contents($httpconf);
            $httpconfcontent = strtr($httpconfcontent,
               array(
                  'php5_module' => 'php4_module',
                  'php5ts.dll' => 'php4ts.dll',
                  'php5apache2.dll' => 'php4apache2.dll',
                  '/php/php-cgi.exe' => '/php/php.exe',
                  '/xampp/php/' => '/xampp/php/php4/'
               )
            );
            file_put_contents($httpconf, $httpconfcontent);
            echo 'done!'."\r\n\r\n";
         }

         echo "  Copy now all php4 dlls to $apachebin\r\n\r\n";

         $dh = opendir($php4dir);
         while ($file = readdir($dh)) {
            if (eregi("(\.dll|\.jar)", $file)) { // Fix by Wiedmann
               $php4file = $partwampp."\php\php4\\".$file;
               $phpcpfile = $partwampp."\apache\bin\\".$file;
               if (file_exists($phpcpfile)) {
                  copy($php4file, $phpcpfile);
                  echo "$php4file => $phpcpfile\r\n";
               }
            }
         }
         closedir($dh);

         echo "  Write the new PHP main version in $phpversionfileroot\r\n";
         $datei = fopen($phpversionfileroot, 'w');
         fputs($datei, "4");
         fclose($datei);
      }

      if (($CS == "5") && ($phpcurrentv == "4")) {
         echo "  Installing PHP5 in XAMPP now!\r\n\r\n";
         sleep(1);

         if (file_exists($phpcurrent)) {
            echo "  Copy the current php.ini to $php4safety ... ";
            copy($phpcurrent, $php4safety);
            echo "done!\r\n";
         }

         if (file_exists($php5safety)) {
            echo "  Copy the php5.ini to $phpcurrent ... ";
            copy($php5safety, $phpcurrent);
            echo "done!\r\n\r\n";
         }

         if (file_exists($httpconf)) { // Fix by Wiedmann
            echo '  Change PHP settings in '.$httpconf.' ... ';
            $httpconfcontent = file_get_contents($httpconf);
            $httpconfcontent = strtr($httpconfcontent,
               array(
                  'php4_module' => 'php5_module',
                  'php4ts.dll' => 'php5ts.dll',
                  'php4apache2.dll' => 'php5apache2.dll',
                  '/php/php.exe' => '/php/php-cgi.exe',
                  '/xampp/php/php4/' => '/xampp/php/'
               )
            );
            file_put_contents($httpconf, $httpconfcontent);
            echo 'done!'."\r\n\r\n";
         }

         echo "  Copy now all php5 dlls to $apachebin\r\n\r\n";

         $dh = opendir($php5dir);
         while ($file = readdir($dh)) {
            if (eregi("(\.dll|\.jar)", $file)) { // Fix by Wiedmann
               $php5file = $partwampp."\php\\".$file;
               $phpcpfile = $partwampp."\apache\bin\\".$file;
               if (file_exists($phpcpfile)) {
                  copy($php5file, $phpcpfile);
                  echo "$php5file => $phpcpfile\r\n";
               }
            }
         }
         closedir($dh);

         echo "  Write the new PHP main version in $phpversionfileroot\r\n";
         $datei = fopen($phpversionfileroot, 'w');
         fputs($datei, "5");
         fclose($datei);
      }

      echo "\r\n  OKAY ... PHP SWITCHING WAS SUCCESSFUL";
      echo "\r\n\r\n  Now you can start the Apache with PHP $CS !";
      echo "\r\n  Nun kannst du den Apache mit PHP $CS starten!";
      sleep(1);

      echo "\r\n\r\n  :-) Kay Vogelgesang & Carsten Wiedmann (www.apachefriends.org)\r\n\r\n";
      exit;
   }
?>

Innocentus
 
Posts: 32
Joined: 28. January 2009 14:10

Re: PHP downgrade

Postby Innocentus » 31. January 2009 23:49

Vielleicht kann mir jetzt jemand bei dem Modifizieren des PHP-Skriptes php-switch.php helfen.
Meines Erachtens muss doch bloß für bessere Unterscheidbarkeit der Ordner PHP4 zu PHP5_1_6-1 umbenannt werden
und dann dort die Dateien durch die von PHP 5.1.6-1 ersetzt werden.

Mit freundlichen Grüßen
Innocentus
Innocentus
 
Posts: 32
Joined: 28. January 2009 14:10


Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 34 guests