Jump to content

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!

Link to post
Share on other sites

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
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.

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.

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.

Link to post
Share on other sites

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
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!

Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

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.