Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 389036

Summary: Update PHP facet version accordingly to project PHP version
Product: z_Archived Reporter: Jacek Pospychala <jacek.pospychala>
Component: PDTAssignee: Martin Eisengardt <martin.eisengardt>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: robert, wywrzal
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Additional patch for sync the php version with facets version none

Description Jacek Pospychala CLA 2012-09-07 06:30:49 EDT
Right now PHP facet version is set to initial project PHP version and there's no way to update it later.
When user changes PHP version in project properties, facet version should be updated accordingly.
Comment 1 Jacek Pospychala CLA 2012-09-07 06:33:08 EDT
Interesting scenario: user created PHP project with PHP 4, added facet that requires PHP 4 and then tries to switch PHP to version 5.
It's impossible because added facet requires older PHP version.
PDT should have proper error message that would let user know what's the problem and how to solve it.
Comment 2 Martin Eisengardt CLA 2012-09-07 06:45:02 EDT
Does PHP already display a warning if the version number you set in the project properties does not match the php executable version number?
I suggest to not confuse the users. So a simple synchronize should solve it. If the user wants to change the version within the project properties the facet should silently update. If the user wants to change the facet version the pdt property should silently be updated.

But I will have a look at the jst plugin. Java does have the same problem: What happens if the user chooses a newer java-version and facets become obselete? We should behave in a similar way to jst.
Comment 3 Jacek Pospychala CLA 2012-09-07 06:58:48 EDT
No there's currently no such warning, because there was no need to have PHP executable with version matching project prefs.

PHP version in PDT prefs is first of all used by PHP parser/validator to validate against proper syntax and there are always parsers for all PHP versions available in preferences combo box.
Launching is different story. When trying to launch a project, PDT will try to take the best available PHP exec, but user might well override it and it's not something we want to warn about in project preferences.

It might turn out as well that most other facets will simply just depend upon PHP facet, not any specific version. 

Alternatively, PDT could try to change facet version, and if it's not possible due to constraints then show an error message and let user deal with it by himself (e.g. reconfigure facets)
Comment 4 Martin Eisengardt CLA 2012-09-07 07:03:51 EDT
OK, I will give it a try (including the error message if it fails). But I will have a look how jst plugin handles it. Actually the facets and pdt version number is some minor information. It only says "I want to develop a project for php 5.3, enable namespace feature etc." It does not guarantee that you have the correct php executable.

With the server feature the importance of the php version grows up. Because the servers may depend on the php version. Let us say, if the user has a project for php version 5.3 he cannot add it to a server that only is configured with php version 5.1.
Comment 6 Martin Eisengardt CLA 2012-09-13 03:38:12 EDT
Created attachment 221013 [details]
Additional patch for sync the php version with facets version

The php version is know synchronized with facets version. If the facets disallow changing the php version a message box is shown with "cancel" button.

However the synchronization on the other side (changing facets php version lead to changes in php preferences) is not finished. First of all we need to prevent endless loops, therefor detect if the facets version change was done manually or programmatically. This is not that easy because the php version is not yet saved to the preferences as soon as the version of tzhe facets will be changed.
Comment 7 Jacek Pospychala CLA 2012-09-13 04:03:33 EDT
thanks Martin!
I'll review your patch.
Comment 8 Martin Eisengardt CLA 2012-09-24 06:06:00 EDT
any news on this patch? :)
Comment 9 Jacek Pospychala CLA 2012-09-24 06:22:40 EDT
ok, I applied it now.
Sorry for the delay!
I thought that maybe there's some better place to hook than PHPCoreOptionsConfigurationBlock. But let's stay with it for now.

thanks Martin!
Comment 10 Michal Niewrzal CLA 2015-02-17 09:53:32 EST
Closing.