Solved How to change multiple users php selection? But php1_select= missing so.... how? Bug?

Richard G

Verified User
Joined
Jul 6, 2008
Messages
12,563
Location
Maastricht
Suppose my first php version is php 7.4. Now I want to change that to for example a 3rd php option and put php 8.0 first for example.

How do we change this for all default users?
As php1_select=1 is not present for default users in their domain.tld.conf file we can't use any command which says "move everybody who has php_select=1 to php_select=3 (for example).

See my post about same thing for listing php versions here:

Shouldn't a php1_select= setting always be present in the domains.tld.conf file for easy listing as well as moving purposes?
 
How do we change this for all default users?
natively you cant. PHP version are position based. You would need to login to every user and set as you like.

There is this as well https://docs.directadmin.com/webservices/php/multiple-php.html#swapping-all-users-php-selection
As php1_select=1 is not present for default users in their domain.tld.conf file we can't use any command which says "move everybody who has php_select=1 to php_select=3 (for example).
correct
Shouldn't a php1_select= setting always be present in the domains.tld.conf file for easy listing as well as moving purposes?
I think there is feedback on this
 
Last edited:
 
No that last link is a workaround and not what I mean. You pointed to the correct issue in post #2 and then striped through, but this is exactly what I'm talking about and how I used it before.

This is what the docs say, so this should be possible but now it's not anymore, so seems to me this is a bug.
 
Exactly, but since it's in the docs it should work. Hence my post here.

And it only does not work anymore because the php1_select= is missing, causing these issues for both listing and changing. So imho a bug.
 
since it's in the docs it should work.
The docs are never current so its either that or a bug.

did you see
and Kristian's post to
 
Yes, I did, but did you too? Part of the solution (which is no solution anymore), that script presented contains:
Code:
    # Is this the version we're looking for?
    if [ $version_current -eq $version_swap1 ]; then
        # replace or add line
        sed -i '/^php1_select
bzzt.. (buzzer on that last line) doesn't exist anymore.

Same for Kristians post.

Issue is that at this moment, some sites do contain the php1_select and most don't. I don't think this is working as designed. All should have some php1_select=X setting.

Thank you, but since this seems a bug to me I'm looking for an answer of @DirectAdmin Support or @smtalk to confirm this as bug and if this can be fixed.
 
:)
I might have misread Kristian's script... Logical, I'm no scripter.
Seems he build in some solution in case no php1_select is present. However still... It's better as things work as designed so also the documentation is correct again.

Maybe @scriptkitty can adjust or explain?
 
This can also create other issues. Could this be fixed @smtalk ?

Check this too:

So if a php setting is removed, the original setting is not removed, which could also cause issues in the future when a new php2, 3 or 4 is created where that user was on. Which is probably undesirable.

If it could be created that users always have a setting which is correct, which would also make moving users choices easier again like it was and is in the docs.
Or keep it like it is now, but if a php version is removed, users having that choice, (for example php selection is 4) that setting is removed as they will fall back to the default anyway.
 
Suppose my first php version is php 7.4. Now I want to change that to for example a 3rd php option and put php 8.0 first for example.

How do we change this for all default users?
As php1_select=1 is not present for default users in their domain.tld.conf file we can't use any command which says "move everybody who has php_select=1 to php_select=3 (for example).

See my post about same thing for listing php versions here:

Shouldn't a php1_select= setting always be present in the domains.tld.conf file for easy listing as well as moving purposes?
I'm not sure what's wrong there? php1_select isn't always there, if it's not there - it's using 1st version of PHP.
 
if it's not there - it's using 1st version of PHP.
Shortly said this was not the case before, so this causes:

1.) Docs commands not working anymore for all users:
because a bunch of them will have no php_select=1 so will not be swapped (since they are not found).

2.) Odd things can happen if you remove a php version and add one later. See my link to the other post. If you have for example 3 php versions and you remove 3. Then all users with choice 3 will automatically be using in fact choice 1 (the default) but in the config still choice 3 is present.
If you add later on another php version on 3 (for example very new or for testing) then these users will suddenly have a totally different PHP version active, while choice 3 is still active in their config.

So that is what's wrong.
 
1) Do you mean you ran the script and it did not work?
2) That's a different issue, I'd suggest having a thread per-issue or at least discuss one thing at a time. Thread is called "How to change multiple users php selection" - let's solve it first?
 
Do you mean you ran the script and it did not work?
I had list script based on that which suddenly did not work anymore.

No I did not run the script yet, as I was too afraid to do it because of this:
Code:
if ! grep -q ^php1_select $i; then
               echo php1_select=2 >> $i

I'm not a scripter, but as far as I can see, this greps php1_select but seems to me that there is no catch if confs do not have a php1_select present, so I'm afraid those domains without php1_select= lines are skipped then, right?

2.) It's not that different, because if all users would have a php1_select= line correct and present, this issue would be solved automatically.
But if you rather discuss this in a seperate topic, that's fine by me too.
 
I'm not sure what the docs example will do. If you would change from php1_select=2 to php1_select=1 it will work. Because for choice 2 there always is a php1_select=2 present in the conf files.

But the issue will occur when you want to change php1_select=1 (or nothing, which is defaulted to 1 but not displayed in .conf file) to php1_select= 2, 3 or 4. Because a bunch of domains won't have the php1_select=1 line present.
 
Back
Top