Jump to content
maxxd

Trying to get phpMyAdmin to work with php7.2 in Vagrant

Recommended Posts

Hi y'all.

First off, I suck at RegEx (like, massively) and I'm not what anyone would call an expert on the command line (I'm not useless, but certainly not a whiz). More than happy to admit that. However, I'm trying to deal with a bug that's apparently cropped up in phpMyAdmin when used on php7.2 - there's this in the conditional:

|| (count($analyzed_sql_results['select_expr'] == 1)

and it needs to be:

|| (count($analyzed_sql_results['select_expr']) == 1)

Now, I'm trying to automate this via a Vagrant provision script, so I figured I'd use sed to replace the line - it's working on the php.ini file just fine. This is what I've come up with as my sed command:

sudo sed -i "s/\(count\(\$analyzed_sql_results\['select_expr'\] == 1 .*/\(count\(\$analyzed_sql_results\['select_expr'\]\) == 1/" /usr/share/phpmyasdmin/libraries/sql.lib.php

and for the life of me I can't figure out why it's not doing anything at all and I don't see any errors in PowerShell.

If it matters, I've added the ppa:nijel/phpmyadmin repository to my apt on the Vagrant machine.

Many thanks in advance for any and all advice!

Share this post


Link to post
Share on other sites

That's not just a bug for 7.2. It's a bug period.

What version are you looking at? Surely it's been patched?

Share this post


Link to post
Share on other sites
Posted (edited)

Yeah, it's clearly a typo. It's been patched (apparently) in 4.8, but even adding the ppa:nijel/phpmyadmin repository, the most recent version I can get is 4.6.6. I could update it manually from the VM command line, but I'm trying to automate this as much as possible with the Vagrant provision script, and I'm admittedly a little behind the times with Vagrant.

Edited by maxxd

Share this post


Link to post
Share on other sites

Speaking of typos, I just saw that I spelled 'phpmyadmin' wrong in the file parameter for the sed call. Corrected that and tested and it still isn't working as I expect it to, so I assume my expression is malformed.

Share this post


Link to post
Share on other sites

Looks like 4.6.6 has the bug and it was the last of its series.

For stuff like this I suggest not sed. That's too fragile. Instead use patches: copy the file, make the edit manually, then use `diff` to create a diff file from the change. `patch` will apply it.
You can also grab the patch from the fix they later applied starting with 4.7.2.

Patches are how I manage old codebases. For an automated deployment I have a patches directory that all get applied after the initial unpack/install step.

Share this post


Link to post
Share on other sites

Sorry if I sound thick here, but is that something I can automate? I can see making the change manually to a local version, then reading that in from the setup shell script and overwriting the downloaded version. Which now that I type it out seems like that may not be a bad idea, actually... Again, I'm not terrible with *nix command line, but I'm not great - diff and patch certainly sound like git or SVN commands and I don't know if that's something I can do while provisioning a virtual machine.

Share this post


Link to post
Share on other sites
Posted (edited)

Creating the patch file is something you do once, and yes you do it manually. You'd add that file to your deployment and use `patch` to apply it.

Thing to look at

You have sed now with a regex, you replace that with patch and a filename.

Edited by requinix

Share this post


Link to post
Share on other sites

Oooh - thank you for the link! I always thought diff and patch were git or SVN specific and had nothing to do with linux. I love it when I learn something new - let me read and experiment and I'll let you know how it goes. Thanks very much!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.