Skip to content

Commit

Permalink
1.32.0
Browse files Browse the repository at this point in the history
[R] Release
[+] interface fixes
  • Loading branch information
wombat committed Sep 17, 2019
1 parent 7e751f9 commit 11e8829
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
/tests export-ignore
/vendor export-ignore
/docs/_deprecated export-ignore
/docs/_todo export-ignore


12 changes: 9 additions & 3 deletions sources/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static function buildUpdateQuery(string $table, array $dataset = [], $whe
public static function buildReplaceQuery(string $table, array $dataset):string;
public static function buildReplaceQueryMVA(string $table, array $dataset, array $mva_attributes):array;

public static function makeInsertQuery($tablename, $dataset):string;
public static function makeUpdateQuery($tablename, $dataset, $where_condition = ''):string;
public static function makeInsertQuery($tablename, &$dataset):string;
public static function makeUpdateQuery($tablename, &$dataset, $where_condition = ''):string;

public static function getRowCount($table, $suffix = NULL):int;
public static function getRowCountConditional($table, $field = '*', $condition = '', $suffix = NULL):int;
Expand Down Expand Up @@ -418,7 +418,7 @@ public static function makeInsertQuery($tablename, &$dataset):string
* @param string $where_condition
* @return bool|string
*/
public static function makeUpdateQuery($tablename, $dataset, $where_condition = ''):string
public static function makeUpdateQuery($tablename, &$dataset, $where_condition = ''):string
{
$query = '';
$r = [];
Expand All @@ -429,6 +429,12 @@ public static function makeUpdateQuery($tablename, $dataset, $where_condition =
$query = "UPDATE `{$tablename}` SET";

foreach ($dataset as $index => $value) {
if (strtoupper(trim($value)) === 'NOW()') {
$set[] = "\r\n `{$index}` = NOW()";
unset($dataset[ $index ]);
continue;
}

$r[] = "\r\n`{$index}` = :{$index}";
}

Expand Down
23 changes: 8 additions & 15 deletions sources/SphinxToolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static function EmulateBuildExcerpts($source, $needle, $options);

use Closure;
use PDO;
use Arris\CLIConsole;

/**
* Class SphinxToolkit
Expand Down Expand Up @@ -111,16 +110,13 @@ public function setRebuildIndexOptions(array $options = []):array
*/
public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index, Closure $make_updateset_method, string $condition = ''):int
{
$mysql_connection = $this->mysql_connection;
$sphinx_connection = $this->sphinx_connection;

$chunk_size = $this->rai_options['chunk_length'];

// truncate
$sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} ");
$this->sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} ");

// get total count
$total_count = $this->mysql_GetRowCount($mysql_connection, $mysql_table, $condition);
$total_count = $this->mysql_GetRowCount($this->mysql_connection, $mysql_table, $condition);
$total_updated = 0;

if ($this->rai_options['log_before_index'])
Expand All @@ -140,7 +136,7 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index,
$query_chunk_data.= $condition != '' ? " WHERE {$condition} " : '';
$query_chunk_data.= "ORDER BY id DESC LIMIT {$offset}, {$chunk_size} ";

$sth = $mysql_connection->query($query_chunk_data);
$sth = $this->mysql_connection->query($query_chunk_data);

// iterate inside chunk
while ($item = $sth->fetch()) {
Expand All @@ -151,7 +147,7 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index,

$update_query = DB::buildReplaceQuery($sphinx_index, $update_set);

$update_statement = $sphinx_connection->prepare($update_query);
$update_statement = $this->sphinx_connection->prepare($update_query);
$update_statement->execute($update_set);
$total_updated++;
} // while
Expand Down Expand Up @@ -189,16 +185,13 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index,
*/
public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_index, Closure $make_updateset_method, string $condition = '', array $mva_indexes_list = []):int
{
$mysql_connection = $this->mysql_connection;
$sphinx_connection = $this->sphinx_connection;

$chunk_size = $this->rai_options['chunk_length'];

// truncate
$sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} ");
$this->sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} ");

// get total count
$total_count = $this->mysql_GetRowCount($mysql_connection, $mysql_table, $condition);
$total_count = $this->mysql_GetRowCount($this->mysql_connection, $mysql_table, $condition);
$total_updated = 0;

if ($this->rai_options['log_before_index'])
Expand All @@ -218,7 +211,7 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde
$query_chunk_data.= $condition != '' ? " WHERE {$condition} " : '';
$query_chunk_data.= "ORDER BY id DESC LIMIT {$offset}, {$chunk_size} ";

$sth = $mysql_connection->query($query_chunk_data);
$sth = $this->mysql_connection->query($query_chunk_data);

// iterate inside chunk
while ($item = $sth->fetch()) {
Expand All @@ -229,7 +222,7 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde

list($update_query, $new_update_set) = DB::buildReplaceQueryMVA($sphinx_index, $update_set, $mva_indexes_list);

$update_statement = $sphinx_connection->prepare($update_query);
$update_statement = $this->sphinx_connection->prepare($update_query);
$update_statement->execute($new_update_set);
$total_updated++;
} // while
Expand Down
4 changes: 0 additions & 4 deletions sources/Toolkit/NginxToolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,10 @@ public static function init($options = [])
* DEBUG: очистка лога в случае, если установлена ENV -> NGINX::LOG_CACHE_CLEANING
*
* @param string $url
* @param string $levels
* @param string $cache_key
* @return bool
*/
public static function clear_nginx_cache(string $url)
{
$unlink_status = true;

if (self::$is_using_cache == 0) {
return false;
}
Expand Down

0 comments on commit 11e8829

Please sign in to comment.