manticoresoftware / manticoresoftware/manticoresearch-php
Unnecessary line in class Create
- Dominant language
- PHP
- Stars
- 211
- Forks
- 39
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 1
Description
Method "setBody" of class "Create" has unnecessary line # 37 (of origin file /phpClient/vendor/manticoresoftware/manticoresearch-php/src/Manticoresearch/Endpoints/Indices/Create.php).
See comment inside code:
public function setBody($params = null)
{
if (isset($this->index)) {
$columns = [];
if (isset($params['columns'])) {
foreach ($params['columns'] as $name => $settings) {
$column = $name . ' ' . $settings['type'];
if (isset($settings['options']) && count($settings['options']) > 0) {
$column .= ' ' . implode(' ', $settings['options']);
}
$columns[] = $column;
}
}
$options = "";
if (isset($params['settings'])) {
foreach ($params['settings'] as $name => $value) {
$options.=" ".$name." = '".$value."'"; // ##### <----- this line is unneccessary, because the same code lower in "else" block
if (is_array($value)) {
foreach ($value as $v) {
$options.=" ".$name." = '".$v."'";
}
} else {
$options.=" ".$name." = '".$value."'"; // #### <----- the same code
}
}
}
return parent::setBody(['query' => "CREATE TABLE ".
(isset($params['silent']) && $params['silent']===true?' IF NOT EXISTS ':'').
$this->index.
(count($columns)>0?"(".implode(",", $columns).")":" ")
.$options]);
}
throw new RuntimeException('Index name is missing.');
}
Contributor guide
No contributing guide indexed for this repository
Research direction
Open phpClient/vendor/manticoresoftware/manticoresearch-php/src/Manticoresearch/Endpoints/Indices/Create.php and inspect Create::setBody, especially the settings loop and its generated options. Confirm the resulting CREATE TABLE body remains correct for scalar and array settings, then verify that the redundant behavior identified in the issue is gone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- search
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100