Switching PHP Versions - Failures and Corrupt php.ini (SOLVED)
Posted by: twohawks (---.dsl.mindspring.com)
Date: May 09, 2011 07:20PM

This issue applies to WampServer 2.0, which I still use...

Summary:
Switching PHP Versions Fails... likely resulting from incorrect "phpversion"s applied in the variable for
FileName: "${c_phpCli}",
...also inappropriate automatic copying over the phpForApache.ini in other bin/php/phpx.x.x/ directories (cross copying) occurs. {don't know why this copy back into the php directory needs to take place, but it does}, effectively obliterating correct versions.


I read a few posts about people having similar problems (problem description details below), without really ever pinning down what is really going on or why, and with no real solutions.

Maybe this is fixed in later versions of WampServer2, however, since I ran into this problem and failed to find the answer here, I am posting the details of this issue, along with the resolution I discovered and am using ..for posterity if nothing else.
Maybe this helps someone else.

@yfastud: did this get fixed in newer releases?

Cheers,
TwoHawks ;^)



##########
PROBLEM DESCRIPTION: When Trying to Switch between them, after Installing additional versions of PHP, I observed the following symptoms:
- may receive errors that certain php extensions are failing to load,
- php version selected may fail to load entirely (crash)
- apache may crash
- apache's resultant php.ini file is the wrong version contents, even after a sucessful switch (during troubleshooting and obtaining limited success, this persisted, albeit, inconsistently)
- phpForApache.ini files in one php installation or the other will soon be overwritten... reverting to being the same as each other in the differnt php installations (one takes over after a while),
- the "Filename" for the "phpclient" variable in wamp configuration and ini files never changes from the originally installed version. (detailed below)



##########
WHATS GOING ON: I discovered that, in my installation anyway,
- $c_phpCliVersion = $wampConf['phpCliVersion']; in config.inc.php ...never changed from the original installed php version

- [phpCli] -- phpCliVersion = "x.x.x" never changes from the original installed php version

- so anywhere-- FileName: "${c_phpCli}"; --is being used (generated from wampmanager.tpl for wampmanager.ini as well as refresh.php) , the pathway to the intended php executable is incorrect (never switches from the originally installed version)

The result is a problem that eventually propogates throughout the installation.



##########
THE SOLUTION I USED: (this is not perfect, but it works well enough)
-------------
FIND IN WAMPSERVER.LIB.PHP
//on modifie la conf de wampserver
$wampIniNewContents['phpIniDir'] = $phpConf['phpIniDir'];
$wampIniNewContents['phpExeDir'] = $phpConf['phpExeDir'];
$wampIniNewContents['phpConfFile'] = $phpConf['phpConfFile'];
$wampIniNewContents['phpVersion'] = $newPhpVersion;
wampIniSet($configurationFile, $wampIniNewContents);

AFTER THIS LINE
$wampIniNewContents['phpVersion'] = $newPhpVersion;
ADD THIS LINE
$wampIniNewContents['phpCliVersion'] = $newPhpVersion;


##########
WHAT THIS DOES:
- the [phpCli] phpCliVersion value in wampmanager.conf will actually toggle when switching php pversion, rather than remaining stagnant.
- the value for the variable $c_phpCliVersion in config.inc.php will change accordingly, rather than remaining seemingly staticly set
- the value for the variable $c_phpCli in refresh.php will change accordingly, rather than remaining seemingly staticly set
- the values for all Filenames will be propogated to the php version selection you make when refresh.php runs
- php.ini in the apache directory will consistently be updated, and in the php directories...without overwriting phpForApache.ini with an incorrect version from another php directory



The only problem with this 'fix' is that the Filname used by different [switchPhpx.x.x] menus, generated under WAMPPHPVERSIONSTART menu-zone that is generated in wampmanager.ini by the relevant wamp php scripts, ...well, those menus shuold continue to use unique values for phpCliVersion's, i.e., those should not stay all the same.

It is not a huge issue, however. The only ramafication I have observed is during the initial switch php wil log a "Notice", one time only, similar to the following:
PHP Notice: Undefined variable: newHttpdContents in S:\wamp\scripts\wampserver.lib.php on line 104


################
TO COMPLETE THE DETAIL associated with this post, below I have copied excerpts from relevant files



#############################################
From WampManager.conf when 5.2.6 chosen
#############################################
[php]
phpVersion = "5.2.6"
phpLastKnown = 5.3.1
phpIniDir = "."
phpConfFile = "php.ini"
phpExeDir = "."


[phpCli]
phpCliVersion = 5.2.6 <--problem child
phpExeFile = php.exe
phpCliFile = php-win.exe

#############################################
From WampManager.conf when 5.3.1 chosen
#############################################
[php]
phpVersion = "5.3.1"
phpLastKnown = 5.2.6
phpIniDir = "."
phpConfFile = "php.ini"
phpExeDir = "."


[phpCli]
phpCliVersion = 5.2.6 <--problem child
phpExeFile = php.exe
phpCliFile = php-win.exe


#############################################
From WampManager.ini when 5.2.6 chosen
#############################################
[phpVersion]
;WAMPPHPVERSIONSTART
Type: item; Caption: "5.2.6"; Action: multi; Actions:switchPhp5.2.6; Glyph: 13
Type: item; Caption: "5.3.1"; Action: multi; Actions:switchPhp5.3.1
Type: separator;
Type: item; Caption: "Get more..."; Action: run; FileName: "C:\Program Files\Mozilla Firefox36x\firefox.exe"; Parameters: "[www.wampserver.com];;
[switchPhp5.2.6]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "switchPhpVersion.php 5.2.6";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;
[switchPhp5.3.1] <<<----------PROBLEM CHILD-------- ...(FileName)------>>>
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "switchPhpVersion.php 5.3.1";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;

;WAMPPHPVERSIONEND
##############################################

#############################################
From WampManager.ini when 5.3.1 chosen
#############################################
[phpVersion]
;WAMPPHPVERSIONSTART
Type: item; Caption: "5.2.6"; Action: multi; Actions:switchPhp5.2.6
Type: item; Caption: "5.3.1"; Action: multi; Actions:switchPhp5.3.1; Glyph: 13
Type: separator;
Type: item; Caption: "Get more..."; Action: run; FileName: "C:\Program Files\Mozilla Firefox36x\firefox.exe"; Parameters: "[www.wampserver.com];;
[switchPhp5.2.6]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "switchPhpVersion.php 5.2.6";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;
[switchPhp5.3.1] <<<----------PROBLEM CHILD-------- ...(FileName)------>>>
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "switchPhpVersion.php 5.3.1";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "S:/wamp/bin/php/php5.2.6/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "S:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;

;WAMPPHPVERSIONEND
##############################################

Love is the Function, No Form is the Tool.

Options: ReplyQuote
Re: Switching PHP Versions - Failures and Corrupt php.ini (SOLVED)
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: May 09, 2011 07:45PM

you shudnt have done any of this...


php cli is set to use the version wamp came with.. IT DOES NOT CHANGE with changing addons

php.ini copys for very good reasons.


there is no bugs in old or new versoins regarding any of this.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Switching PHP Versions - Failures and Corrupt php.ini (SOLVED)
Posted by: twohawks (---.dsl.mindspring.com)
Date: May 09, 2011 08:10PM

Well, I could not find any other solution.

Was the problem made clear?

What would you recommend?

Love is the Function, No Form is the Tool.

Options: ReplyQuote
Re: Switching PHP Versions - Failures and Corrupt php.ini (SOLVED)
Posted by: twohawks (---.dsl.mindspring.com)
Date: May 10, 2011 12:32AM

PS: If you feel my 'solution post' is terribly misguided, then either please go ahead and delete it, or ask me to and I will.

It would help, however, if there were proper review by someone who knows better for addressing the problems described in the section labelled "PROBLEM DESCRIPTION" - which provides fairly explicit reference.

Thank you.
TwoHawks

Love is the Function, No Form is the Tool.

Options: ReplyQuote
Re: Switching PHP Versions - Failures and Corrupt php.ini (SOLVED)
Posted by: twohawks (---.dsl.mindspring.com)
Date: May 13, 2011 02:37AM

It would be nice to hear back from you , Steven.
Should be obvious that in my last post my reference to "someone who knows better" was to you, of course.
I re-reviewed everything... all I did and what its doing before and after the change.
In my situation anyway, I cannot see any alternative solution to my problem.

Cheers,
TwoHawks

PS: It should be apparent if you read my post carefully that I understand that, as you ssay, "php.ini copys for very good reasons"... however, mine were cross-copying, overwriting settings files in "the other" php installation source... which results in all my settings for each installation ultimately becoming confused and lost.

Example, launch wamp with php5.2.x, switch to 5.3.x (errors occur), then switch back... the new php.ini is copied from phpForApache.ini from directory 5.2.x BUT which has been mysteriously overwritten with the one from 5.3.x, so the 5.2.x one is 'gone forever" ...kind of thing. The correction I applied allows the files to update without cross-overwriting from another php installation... thus apache always gets "the right one" when switching now.

Love is the Function, No Form is the Tool.

Options: ReplyQuote


Sorry, only registered users may post in this forum.