fix update from 1.5 error

This commit is contained in:
xiaomlove
2022-03-08 21:01:12 +08:00
parent 98a33baf81
commit 57569d7c51
5 changed files with 34 additions and 11 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ return [
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',
'prefix_indexes' => true, 'prefix_indexes' => true,
'strict' => true, 'strict' => false,
'engine' => null, 'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([ 'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
+8 -3
View File
@@ -3088,7 +3088,7 @@ function torrenttable($rows, $variant = "torrent") {
$torrentSeedingLeechingStatus = $torrent->listLeechingSeedingStatus($CURUSER['id'], $torrentIdArr); $torrentSeedingLeechingStatus = $torrent->listLeechingSeedingStatus($CURUSER['id'], $torrentIdArr);
$tagRep = new \App\Repositories\TagRepository(); $tagRep = new \App\Repositories\TagRepository();
$tagCollection = $tagRep->createBasicQuery()->get(); $tagCollection = $tagRep->createBasicQuery()->get();
$tagIdStr = $tagCollection->implode('id', ','); $tagIdStr = $tagCollection->implode('id', ',') ?: '0';
$torrentTagCollection = \App\Models\TorrentTag::query()->whereIn('torrent_id', $torrentIdArr)->orderByRaw("field(tag_id,$tagIdStr)")->get(); $torrentTagCollection = \App\Models\TorrentTag::query()->whereIn('torrent_id', $torrentIdArr)->orderByRaw("field(tag_id,$tagIdStr)")->get();
$tagKeyById = $tagCollection->keyBy('id'); $tagKeyById = $tagCollection->keyBy('id');
$torrentTagResult = $torrentTagCollection->groupBy('torrent_id'); $torrentTagResult = $torrentTagCollection->groupBy('torrent_id');
@@ -3287,8 +3287,13 @@ foreach ($rows as $row)
/** /**
* render tags * render tags
*/ */
$tagIdArr = $torrentTagResult->get($id)->pluck('tag_id')->toArray(); $tagOwns = $torrentTagResult->get($id);
$tags = $tagRep->renderSpan($tagKeyById, $tagIdArr); if ($tagOwns) {
$tags = $tagRep->renderSpan($tagKeyById, $tagOwns->pluck('tag_id')->toArray());
} else {
$tags = '';
}
if ($displaysmalldescr){ if ($displaysmalldescr){
//small descr //small descr
$dissmall_descr = trim($row["small_descr"]); $dissmall_descr = trim($row["small_descr"]);
+10 -4
View File
@@ -106,7 +106,7 @@ class Install
$filename = basename($path); $filename = basename($path);
$count = preg_match('/create_(.*)_table.php/', $filename, $matches); $count = preg_match('/create_(.*)_table.php/', $filename, $matches);
if ($count) { if ($count) {
$tables[$matches[1]] = $filename; $tables[$matches[1]] = "database/migrations/$filename";
} }
} }
return $tables; return $tables;
@@ -202,7 +202,7 @@ class Install
require $originalConfigFile; require $originalConfigFile;
$settings = require $defaultSettingsFile; $settings = require $defaultSettingsFile;
$settingsFromDb = []; $settingsFromDb = [];
if (get_row_count('settings') > 0) { if (NexusDB::schema()->hasTable('settings') && get_row_count('settings') > 0) {
$settingsFromDb = get_setting(); $settingsFromDb = get_setting();
} }
$this->doLog("settings form db: " . json_encode($settingsFromDb)); $this->doLog("settings form db: " . json_encode($settingsFromDb));
@@ -424,7 +424,7 @@ class Install
$this->doLog("[CREATE ENV] key: $key, new value: $value from example."); $this->doLog("[CREATE ENV] key: $key, new value: $value from example.");
$newData[$key] = $value; $newData[$key] = $value;
} }
if ($scene == 'install') { if ($scene == 'install' || !file_exists($envFile)) {
if ($key == 'APP_ENV') { if ($key == 'APP_ENV') {
$newData[$key] = 'production'; $newData[$key] = 'production';
} }
@@ -487,6 +487,9 @@ class Install
public function saveSettings($settings) public function saveSettings($settings)
{ {
if (!NexusDB::schema()->hasTable('settings')) {
$this->runMigrate('database/migrations/2021_06_08_113437_create_settings_table.php');
}
foreach ($settings as $prefix => $group) { foreach ($settings as $prefix => $group) {
$this->doLog("[SAVE SETTING], prefix: $prefix, nameAndValues: " . json_encode($group)); $this->doLog("[SAVE SETTING], prefix: $prefix, nameAndValues: " . json_encode($group));
saveSetting($prefix, $group); saveSetting($prefix, $group);
@@ -549,7 +552,9 @@ class Install
} }
$command = "php " . ROOT_PATH . "artisan migrate"; $command = "php " . ROOT_PATH . "artisan migrate";
if (!is_null($path)) { if (!is_null($path)) {
$command .= " --path=$path"; foreach ((array)$path as $key => $value) {
$command .= " --path=$value";
}
} }
$command .= " --force"; $command .= " --force";
$this->executeCommand($command); $this->executeCommand($command);
@@ -582,4 +587,5 @@ class Install
$this->doLog("[DATABASE_SEED] success."); $this->doLog("[DATABASE_SEED] success.");
} }
} }
} }
+1
View File
@@ -194,6 +194,7 @@ class Update extends Install
} else { } else {
$this->doLog("no need to run [MIGRATE_TORRENT_TAG]"); $this->doLog("no need to run [MIGRATE_TORRENT_TAG]");
} }
} }
private function migrateAttendance() private function migrateAttendance()
+14 -3
View File
@@ -44,6 +44,13 @@ if ($currentStep == 2) {
'name' => 'Description', 'name' => 'Description',
'published_at' => 'Release at', 'published_at' => 'Release at',
]; ];
try {
$timezone = nexus_env('TIMEZONE');
} catch (\Exception $exception) {
$update->doLog("no .env file, release time is github original");
$timezone = null;
}
$tableRows[] = [ $tableRows[] = [
'checkbox' => sprintf('<input type="radio" name="version_url" value="manual"/>'), 'checkbox' => sprintf('<input type="radio" name="version_url" value="manual"/>'),
'tag_name' => 'Manual', 'tag_name' => 'Manual',
@@ -51,8 +58,10 @@ if ($currentStep == 2) {
'published_at' => '---', 'published_at' => '---',
]; ];
$latestCommit = $update->getLatestCommit(); $latestCommit = $update->getLatestCommit();
$time = \Carbon\Carbon::parse($latestCommit['committer']['date']); $time = \Carbon\Carbon::parse($latestCommit['commit']['committer']['date']);
$time->tz = nexus_env('TIMEZONE'); if ($timezone) {
$time->tz = $timezone;
}
$tableRows[] = [ $tableRows[] = [
'checkbox' => sprintf('<input type="radio" name="version_url" value="development|%s"/>', $latestCommit['sha']), 'checkbox' => sprintf('<input type="radio" name="version_url" value="development|%s"/>', $latestCommit['sha']),
'tag_name' => 'Latest development code', 'tag_name' => 'Latest development code',
@@ -64,7 +73,9 @@ if ($currentStep == 2) {
continue; continue;
} }
$time = \Carbon\Carbon::parse($version['published_at']); $time = \Carbon\Carbon::parse($version['published_at']);
$time->tz = nexus_env('TIMEZONE'); if ($timezone) {
$time->tz = $timezone;
}
$versionUrl = $version['tag_name'] . '|' . $version['tarball_url']; $versionUrl = $version['tag_name'] . '|' . $version['tarball_url'];
$checked = !empty($_REQUEST['version_url']) && $_REQUEST['version_url'] == $versionUrl ? ' checked' : ''; $checked = !empty($_REQUEST['version_url']) && $_REQUEST['version_url'] == $versionUrl ? ' checked' : '';
$tableRows[] = [ $tableRows[] = [