Skip to content

Commit

Permalink
Merge pull request #345 from gianluigi-icit/master
Browse files Browse the repository at this point in the history
fix replace bug on regex using webui
  • Loading branch information
jack-interconnectit committed Oct 5, 2020
2 parents e71e0b2 + 51d2d3d commit 7231e53
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 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.3
* Fix regex search/replace using WebUI

# Version 4.1.2
* Now you can suppress the checks for PHP and be able to run this tool in an old setup

Expand Down
13 changes: 10 additions & 3 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.2
* Safe Search and Replace on Database with Serialized Data v4.1.3
* Copyright © 2020 Interconnect IT Limited
*
* This script is to solve the problem of doing database search and replace when
Expand Down Expand Up @@ -231,7 +231,14 @@ public function response(
if ( $this->regex_x ) {
$mods .= 'x';
}
$this->search = '/' . $this->search . '/' . $mods;

if(is_array($this->search)){
foreach ($this->search as $searchKey => $searchString){
$this->search[$searchKey] = '/' . $searchString . '/' . $mods;
}
}else{
$this->search = '/' . $this->search . '/' . $mods;
}
}

// call search replace class
Expand Down Expand Up @@ -912,7 +919,7 @@ class="db-required run-script"/>

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

<h2>Safe Search and Replace on Database with Serialized Data v4.1.2</h2>
<h2>Safe Search and Replace on Database with Serialized Data v4.1.3</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.2",
"version": "4.1.3",
"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
10 changes: 6 additions & 4 deletions srdb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class icit_srdb {
public $ssl_ca = false;
public $ssl_ca_dir = null;
public $ssl_cipher = null;
public $ssl_check = true;

public $debug = false;


Expand Down Expand Up @@ -280,14 +282,14 @@ public function __construct( $args ) {
}

// set class vars
foreach ( $args as $name => $value ) {
foreach ( $args as $property => $value ) {
if ( is_string( $value ) ) {
$value = stripcslashes( $value );
}
if ( is_array( $value ) ) {
$value = array_map( 'stripcslashes', $value );
}
$this->set( $name, $value );
$this->$property = $value;
}

// only for non cli call, cli set no timeout, no memory limit
Expand Down Expand Up @@ -545,8 +547,8 @@ public function connect_pdo() {
$params = array();

foreach ( $params_map as $property => $pdo_param ) {
if ( $this->get( $property ) ) {
$params[ $pdo_param ] = $this->get( $property );
if ( $this->$property ) {
$params[ $pdo_param ] = $this->$property;
}
}

Expand Down

0 comments on commit 7231e53

Please sign in to comment.