Skip to content

Commit

Permalink
remove mbpop
Browse files Browse the repository at this point in the history
remove mbpush
user utf8 in mb_ functions
  • Loading branch information
versh23 committed Jan 29, 2015
1 parent 4ec1495 commit 9eb490f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 54 deletions.
40 changes: 0 additions & 40 deletions src/Drivers/SimpleConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ class SimpleConnection implements ConnectionInterface
*/
protected $connection_params = array('host' => '127.0.0.1', 'port' => 9306, 'socket' => null);

/**
* Internal Encoding
*
* @var string
*/
protected $internal_encoding = null;

/**
* Disables any warning outputs returned on the \MySQLi connection with @ prefix.
*
Expand Down Expand Up @@ -105,16 +98,6 @@ public function getParams()
return $this->connection_params;
}

/**
* Returns the internal encoding.
*
* @return string current multibyte internal encoding
*/
public function getInternalEncoding()
{
return $this->internal_encoding;
}

/**
* Returns the current \mysqli connection established.
*
Expand Down Expand Up @@ -163,7 +146,6 @@ public function connect($suppress_error = false)

$conn->set_charset('utf8');
$this->connection = $conn;
$this->mbPush();

return true;
}
Expand All @@ -189,7 +171,6 @@ public function ping()
*/
public function close()
{
$this->mbPop();
$this->getConnection()->close();
$this->connection = null;
}
Expand Down Expand Up @@ -393,25 +374,4 @@ public function quoteArr(Array $array = array())
return $result;
}

/**
* Enter UTF-8 multi-byte workaround mode.
*/
public function mbPush()
{
$this->internal_encoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');

return $this;
}

/**
* Exit UTF-8 multi-byte workaround mode.
*/
public function mbPop()
{
mb_internal_encoding($this->internal_encoding);
$this->internal_encoding = null;

return $this;
}
}
6 changes: 3 additions & 3 deletions src/SphinxQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ public function escapeMatch($string)
return $string->value();
}

return mb_strtolower(str_replace(array_keys($this->escape_full_chars), array_values($this->escape_full_chars), $string));
return mb_strtolower(str_replace(array_keys($this->escape_full_chars), array_values($this->escape_full_chars), $string), 'utf8');
}

/**
Expand All @@ -1240,7 +1240,7 @@ public function halfEscapeMatch($string)
$string = str_replace(array_keys($this->escape_half_chars), array_values($this->escape_half_chars), $string);

// this manages to lower the error rate by a lot
if (mb_substr_count($string, '"') % 2 !== 0) {
if (mb_substr_count($string, '"', 'utf8') % 2 !== 0) {
$string .= '"';
}

Expand All @@ -1253,7 +1253,7 @@ public function halfEscapeMatch($string)
'/(\S+)\s+-\s+(\S+)/u' => '\1 \- \2',
);

$string = mb_strtolower(preg_replace(array_keys($from_to_preg), array_values($from_to_preg), $string));
$string = mb_strtolower(preg_replace(array_keys($from_to_preg), array_values($from_to_preg), $string), 'utf8');

return $string;
}
Expand Down
11 changes: 0 additions & 11 deletions tests/classes/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,4 @@ public function testQuoteArr()
);
}

public function testMbPush()
{
$this->connection->mbPush();
$this->assertEquals('UTF-8', $this->connection->getInternalEncoding());
}

public function testMbPop()
{
$this->connection->mbPush()->mbPop();
$this->assertEquals(null, $this->connection->getInternalEncoding());
}
}

0 comments on commit 9eb490f

Please sign in to comment.