From 6fd5489437671188d3077044992d209bb0c54ac1 Mon Sep 17 00:00:00 2001 From: Gianluigi Cusimano Date: Mon, 11 May 2020 16:55:26 +0100 Subject: [PATCH 1/2] allow old php versions --- CHANGELOG.md | 3 +++ README.md | 5 ++++- index.php | 4 ++-- package.json | 2 +- srdb.cli.php | 26 ++++++++++++++++---------- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2f3e1..a52b4d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +# Version 4.1.2 + * Now you can suppress the checks for PHP and be able to run this tool in an old setup + # Version 4.1.1 * Class autoloader in composer.json diff --git a/README.md b/README.md index a9369a6..fc9529c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/interconnectit/Search-Replace-DB.svg?branch=4.0)](https://travis-ci.org/interconnectit/Search-Replace-DB) -# Search Replace DB - v4.1.1 +# Search Replace DB - v4.1.2 This script was made to aid the process of migrating PHP and MySQL based websites. Works with most common CMSes. @@ -146,6 +146,9 @@ Type `php srdb.cli.php` to run the program. Type `php srdb.cli.php --ssl-check [true|false] Check the SSL certificate, default to True. + --allow-old-php [true|false] + Suppress the check for PHP version, use it at your own risk! + --help Displays this help message ;) ``` diff --git a/index.php b/index.php index 2fce750..7d27563 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ /** * - * Safe Search and Replace on Database with Serialized Data v4.1.1 + * Safe Search and Replace on Database with Serialized Data v4.1.2 * Copyright © 2020 Interconnect IT Limited * * This script is to solve the problem of doing database search and replace when @@ -912,7 +912,7 @@ class="db-required run-script"/>

interconnect/it

-

Safe Search and Replace on Database with Serialized Data v4.1.1

+

Safe Search and Replace on Database with Serialized Data v4.1.2

This developer/sysadmin tool carries out search/replace functions on MySQL DBs and can handle serialised PHP Arrays and Objects.

diff --git a/package.json b/package.json index 57a1919..90c2bc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "search-replace-db", - "version": "4.1.1", + "version": "4.1.2", "description": "A PHP search replace tool for quickly modifying a string throughout a database. Useful for changing the base URL when migrating a WordPress site from development to production.", "main": "srdb.cli.php", "directories": { diff --git a/srdb.cli.php b/srdb.cli.php index bdcab22..9df2d75 100755 --- a/srdb.cli.php +++ b/srdb.cli.php @@ -80,6 +80,8 @@ [ '', 'ssl-cipher:', 'Define the cipher to use for SSL.', ], [ '', 'ssl-check:', 'Check the SSL certificate, default to True.', '[true|false]' ], + [ '', 'allow-old-php:', 'Suppress the check for PHP version, use it at your own risk!', '[true|false]' ], + [ '', 'help', 'Displays this help message ;)', ], ); @@ -156,12 +158,6 @@ function strip_colons( $string ) { // missing field flag, show all missing instead of 1 at a time $missing_arg = false; -if ( version_compare( PHP_VERSION, '7.3' ) < 0 ) { - fwrite( STDERR, - "This script has been tested using PHP7.3 +, whereas your version is: " . PHP_VERSION . ". Although this script may work with older versions you do so at your own risk. Please update php and try again. \n" ); - exit( 1 ); -} - if ( ! extension_loaded( "mbstring" ) ) { fwrite( STDERR, "This script requires mbstring. Please install mbstring and try again.\n" ); exit ( 1 ); @@ -184,10 +180,11 @@ function strip_colons( $string ) { // new args array $args = array( - 'verbose' => true, - 'ssl_check' => true, - 'dry_run' => false, - 'debug' => false + 'verbose' => true, + 'ssl_check' => true, + 'dry_run' => false, + 'debug' => false, + 'allow_old_php' => false ); // create $args array @@ -212,6 +209,7 @@ function strip_colons( $string ) { // boolean options. case 'debug': case 'ssl-check': + case 'allow-old-php': case 'verbose': $value = (boolean) filter_var( $value, FILTER_VALIDATE_BOOLEAN ); break; @@ -223,6 +221,14 @@ function strip_colons( $string ) { $args[ $key ] = $value; } +if ( $args['allow_old_php'] === false ) { + if ( version_compare( PHP_VERSION, '7.3' ) < 0 ) { + fwrite( STDERR, + "This script has been tested using PHP7.3 +, whereas your version is: " . PHP_VERSION . ". Although this script may work with older versions you do so at your own risk. Please update php and try again. \n" ); + exit( 1 ); + } +} + // modify the log output class icit_srdb_cli extends icit_srdb { public function log( $type = '' ) { From 0f8cdacec3bd1a7305f988a7b6337bd9053b3d56 Mon Sep 17 00:00:00 2001 From: Gianluigi Cusimano Date: Tue, 12 May 2020 09:32:18 +0100 Subject: [PATCH 2/2] no need to use tru/false for allow old php --- srdb.cli.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/srdb.cli.php b/srdb.cli.php index 9df2d75..c89e8aa 100755 --- a/srdb.cli.php +++ b/srdb.cli.php @@ -80,7 +80,7 @@ [ '', 'ssl-cipher:', 'Define the cipher to use for SSL.', ], [ '', 'ssl-check:', 'Check the SSL certificate, default to True.', '[true|false]' ], - [ '', 'allow-old-php:', 'Suppress the check for PHP version, use it at your own risk!', '[true|false]' ], + [ '', 'allow-old-php', 'Suppress the check for PHP version, use it at your own risk!' ], [ '', 'help', 'Displays this help message ;)', ], ); @@ -187,6 +187,10 @@ function strip_colons( $string ) { 'allow_old_php' => false ); +if ( isset( $options['allow-old-php'] ) ) { + $args['allow_old_php'] = true; +} + // create $args array foreach ( $options as $key => $value ) { @@ -209,7 +213,6 @@ function strip_colons( $string ) { // boolean options. case 'debug': case 'ssl-check': - case 'allow-old-php': case 'verbose': $value = (boolean) filter_var( $value, FILTER_VALIDATE_BOOLEAN ); break;