Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Carlos Rodríguez del Pino committed Jun 6, 2024
2 parents e314071 + 0492b1b commit 5d44da9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
18 changes: 9 additions & 9 deletions similarity/similarity_base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ class vpl_files_pair {
static protected $maxs3 = 100;
public $first;
public $second;
protected $selected;
protected $s1;
protected $s2;
protected $s3;
protected $id;
protected $level;
protected $level1;
protected $level2;
protected $level3;
public $selected;
public $s1;
public $s2;
public $s3;
public $id;
public $level;
public $level1;
public $level2;
public $level3;
private $clusternumber;
public function __construct($first = null, $second = null, $s1 = 0, $s2 = 0, $s3 = 0) {
$this->first = $first;
Expand Down
33 changes: 32 additions & 1 deletion vpl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,15 @@ public static function get_db_record($table, $id) {
self::$instancescache[$table] = [];
}
if (! isset(self::$instancescache[$table][$id])) {
self::$instancescache[$table][$id] = $DB->get_record($table, ["id" => $id]);
$instance = $DB->get_record($table, ["id" => $id]);
if ($instance !== false && $table == VPL) {
self::set_null_field_empty($instance);
}
self::$instancescache[$table][$id] = $instance;
}
return self::$instancescache[$table][$id];
}

/**
* Remove one record or all records from cache
*
Expand All @@ -221,6 +226,32 @@ public static function reset_db_cache($table = 'all', $id = -1) {
}
}

/**
* Set string field with null to empty string.
*
* @param object $vplinstace
* @return void
*/
public static function set_null_field_empty($vplinstace) {
$fields = [
'shortdescription',
'intro',
'requirednet',
'password',
'variationtitle',
'jailservers',
'reductionbyevaluation',
'sebkeys',
'runscript',
'debugscript',
];
foreach ($fields as $field) {
if (property_exists($vplinstace, $field) && $vplinstace->$field == null) {
$vplinstace->$field = '';
}
}
}

/**
* Constructor
*
Expand Down

0 comments on commit 5d44da9

Please sign in to comment.