maxxd Posted October 6, 2018 Share Posted October 6, 2018 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! Quote Link to comment Share on other sites More sharing options...
requinix Posted October 6, 2018 Share Posted October 6, 2018 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? Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 7, 2018 Author Share Posted October 7, 2018 (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 October 7, 2018 by maxxd Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 7, 2018 Author Share Posted October 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 7, 2018 Share Posted October 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 7, 2018 Author Share Posted October 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 7, 2018 Share Posted October 7, 2018 (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 October 7, 2018 by requinix Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 7, 2018 Author Share Posted October 7, 2018 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.