Skip to content

Commit

Permalink
Merge pull request #332 from gianluigi-icit/master
Browse files Browse the repository at this point in the history
allow old php versions
  • Loading branch information
jack-interconnectit authored May 12, 2020
2 parents 4a6087a + 0f8cdac commit 0464599
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 ;)
```
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -912,7 +912,7 @@ class="db-required run-script"/>

<h1 class="branding">interconnect/it</h1>

<h2>Safe Search and Replace on Database with Serialized Data v4.1.1</h2>
<h2>Safe Search and Replace on Database with Serialized Data v4.1.2</h2>

<p>This developer/sysadmin tool carries out search/replace functions on MySQL DBs and can handle serialised
PHP Arrays and Objects.</p>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
29 changes: 19 additions & 10 deletions srdb.cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!' ],

[ '', 'help', 'Displays this help message ;)', ],
);

Expand Down Expand Up @@ -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 );
Expand All @@ -184,12 +180,17 @@ 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
);

if ( isset( $options['allow-old-php'] ) ) {
$args['allow_old_php'] = true;
}

// create $args array
foreach ( $options as $key => $value ) {

Expand Down Expand Up @@ -223,6 +224,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 = '' ) {
Expand Down

0 comments on commit 0464599

Please sign in to comment.