diff --git a/composer.json b/composer.json index 7d41ad145b..3d46cf3fd2 100644 --- a/composer.json +++ b/composer.json @@ -124,7 +124,5 @@ "cakephp/plugin-installer": true, "dealerdirect/phpcodesniffer-composer-installer": true } - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/plugins/baser-core/config/setting.php b/plugins/baser-core/config/setting.php index 57ad347476..c85049dc67 100644 --- a/plugins/baser-core/config/setting.php +++ b/plugins/baser-core/config/setting.php @@ -173,7 +173,16 @@ /** * 現在のリクエストのホスト */ - 'host' => (isset($_SERVER['HTTP_HOST']))? $_SERVER['HTTP_HOST'] : null + 'host' => (isset($_SERVER['HTTP_HOST']))? $_SERVER['HTTP_HOST'] : null, + /** + * インストール済かどうか + * + * BaserCorePlugin::bootstrap() で設定する + * bootstrap の方が呼び出し順が早いため、こちらで設定すると再初期化となってしまうため + * コメントアウトのままとする + * ここで別途判定を入れた場合ユニットテストがやりにくくなるのでそのままにしておく + */ + // 'isInstalled' => null, ], /** @@ -561,21 +570,6 @@ ] ], - /** - * リクエスト情報 - */ - 'BcRequest' => [ - // アセットファイルかどうか - 'asset' => false, - // Router がロード済かどうか - // TODO 不要か確認 - 'routerLoaded' => false, - // アップデーターかどうか - 'isUpdater' => false, - // メンテナンスかどうか - 'isMaintenance' => false, - ], - /** * プレフィックス認証 * diff --git a/plugins/baser-core/src/BaserCorePlugin.php b/plugins/baser-core/src/BaserCorePlugin.php index 0d0f0295c4..aa49ab0beb 100644 --- a/plugins/baser-core/src/BaserCorePlugin.php +++ b/plugins/baser-core/src/BaserCorePlugin.php @@ -47,6 +47,7 @@ use Cake\I18n\I18n; use Cake\Log\Log; use Cake\ORM\TableRegistry; +use Cake\Routing\Middleware\RoutingMiddleware; use Cake\Routing\RouteBuilder; use Cake\Routing\Router; use Cake\Utility\Inflector; @@ -91,8 +92,8 @@ public function bootstrap(PluginApplicationInterface $app): void * インストールされてない場合のテストをできるようにするため、Configure の設定を優先する */ $hasInstall = file_exists(CONFIG . 'install.php'); - if (is_null(Configure::read('BcRequest.isInstalled'))) { - Configure::write('BcRequest.isInstalled', $hasInstall); + if (is_null(Configure::read('BcEnv.isInstalled'))) { + Configure::write('BcEnv.isInstalled', $hasInstall); } /** @@ -281,7 +282,7 @@ function loadPlugin(PluginApplicationInterface $application, $plugin, $priority) public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue { $middlewareQueue - ->prepend(new BcRequestFilterMiddleware()) + ->insertBefore(RoutingMiddleware::class, new BcRequestFilterMiddleware()) ->insertBefore(CsrfProtectionMiddleware::class, new AuthenticationMiddleware($this)) ->add(new BcAdminMiddleware()) ->add(new BcFrontMiddleware()) @@ -607,6 +608,17 @@ function(RouteBuilder $routes) { parent::routes($routes); } + /** + * 初期データ読み込み時の更新処理 + * @param array $options + * @return void + */ + public function updateDefaultData($options = []) : void + { + // コンテンツの作成日を更新 + $this->updateDateNow('BaserCore.Contents', ['created_date'], [], $options); + } + /** * services * @param ContainerInterface $container diff --git a/plugins/baser-core/src/BcPlugin.php b/plugins/baser-core/src/BcPlugin.php index 502421077a..064f3d7385 100644 --- a/plugins/baser-core/src/BcPlugin.php +++ b/plugins/baser-core/src/BcPlugin.php @@ -621,7 +621,11 @@ public function updateDateNow(string $table, array $fields, array $conditions = $options = array_merge([ 'connection' => 'default' ], $options); - $table = TableRegistry::getTableLocator()->get($table, ['connectionName' => $options['connection']]); + $tableOptions = []; + if($options['connection'] && $options['connection'] !== 'default') { + $tableOptions = ['connectionName' => $options['connection']]; + } + $table = TableRegistry::getTableLocator()->get($table, $tableOptions); $beforeSaveEvents = BcUtil::offEvent($table->getEventManager(), 'Model.beforeSave'); $afterSaveEvents = BcUtil::offEvent($table->getEventManager(), 'Model.afterSave'); diff --git a/plugins/baser-core/src/Controller/Admin/PluginsController.php b/plugins/baser-core/src/Controller/Admin/PluginsController.php index 2e93157d70..d9d66aca64 100644 --- a/plugins/baser-core/src/Controller/Admin/PluginsController.php +++ b/plugins/baser-core/src/Controller/Admin/PluginsController.php @@ -34,6 +34,7 @@ class PluginsController extends BcAdminAppController /** * Before Filter * @param \Cake\Event\EventInterface $event An Event instance + * @return Response|void * @checked * @unitTest * @noTodo @@ -43,7 +44,6 @@ public function beforeFilter(EventInterface $event) $response = parent::beforeFilter($event); if($response) return $response; $this->FormProtection->setConfig('unlockedActions', ['reset_db', 'update_sort', 'batch']); - if(Configure::read('BcRequest.isUpdater')) $this->Authentication->allowUnauthenticated(['update']); } /** diff --git a/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php b/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php index 38b85773df..fb4b201ae3 100644 --- a/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php +++ b/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php @@ -42,19 +42,13 @@ class BcRedirectMainSiteMiddleware implements MiddlewareInterface * @param RequestHandlerInterface $handler * @return ResponseInterface * @checked + * @noTodo */ public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { - // TODO 対象サイトでの存在確認ができていない - // ルーティング後だと、ルーティングで失敗するので、ルーティング前に実行する必要があるが、 - // ルーティング前だと対象サイトでの存在確認ができないため、現在は利用していない。 - // ルーティングに組み込むことを検討する - if (Configure::read('BcRequest.isUpdater')) { - return $handler->handle($request); - } if ($request->is('admin') || !BcUtil::isInstalled()) { return $handler->handle($request); } diff --git a/plugins/baser-core/src/Middleware/BcRedirectSubSiteMiddleware.php b/plugins/baser-core/src/Middleware/BcRedirectSubSiteMiddleware.php index 5ed4c19a79..3c976a03e4 100644 --- a/plugins/baser-core/src/Middleware/BcRedirectSubSiteMiddleware.php +++ b/plugins/baser-core/src/Middleware/BcRedirectSubSiteMiddleware.php @@ -56,9 +56,6 @@ public function process( RequestHandlerInterface $handler ): ResponseInterface { - if (Configure::read('BcRequest.isUpdater')) { - return $handler->handle($request); - } if ($request->is('admin') || !BcUtil::isInstalled()) { return $handler->handle($request); } diff --git a/plugins/baser-core/src/Middleware/BcRequestFilterMiddleware.php b/plugins/baser-core/src/Middleware/BcRequestFilterMiddleware.php index 8aea693ad2..309865252d 100644 --- a/plugins/baser-core/src/Middleware/BcRequestFilterMiddleware.php +++ b/plugins/baser-core/src/Middleware/BcRequestFilterMiddleware.php @@ -50,12 +50,6 @@ public function process( $response = $this->redirectIfIsDeviceFile($request); if($response) return $response; } - - if ($this->isAsset($request)) { - Configure::write('BcRequest.asset', true); - return new Response(); - } - $request = $this->addDetectors($request); /** @@ -122,7 +116,6 @@ public function getDetectorConfigs() { $configs = []; $configs['admin'] = $this->isAdmin(...); - $configs['asset'] = $this->isAsset(...); $configs['install'] = $this->isInstall(...); $configs['maintenance'] = $this->isMaintenance(...); $configs['page'] = $this->isPage(...); @@ -167,30 +160,6 @@ public function isAdmin(ServerRequestInterface $request) return (bool)preg_match($regex, $request->getPath()); } - /** - * アセットのURLかどうかを判定 - * - * @param ServerRequestInterface $request リクエスト - * @return bool - * @checked - * @noTodo - * @unitTest - */ - public function isAsset(ServerRequestInterface $request) - { - $dirs = ['css', 'js', 'img']; - $exts = ['css', 'js', 'gif', 'jpg', 'jpeg', 'png', 'ico', 'svg', 'swf']; - - $dirRegex = implode('|', $dirs); - $extRegex = implode('|', $exts); - - $assetRegex = '/^\/(' . $dirRegex . ')\/.+\.(' . $extRegex . ')$/'; - $themeAssetRegex = '/^\/theme\/[^\/]+?\/(' . $dirRegex . ')\/.+\.(' . $extRegex . ')$/'; - - $uri = $request->getPath(); - return preg_match($assetRegex, $uri) || preg_match($themeAssetRegex, $uri); - } - /** * インストール用のURLかどうかを判定 * [注]ルーターによるURLパース後のみ diff --git a/plugins/baser-core/src/Service/BcDatabaseService.php b/plugins/baser-core/src/Service/BcDatabaseService.php index 850f81442e..b6eeaa0bcc 100644 --- a/plugins/baser-core/src/Service/BcDatabaseService.php +++ b/plugins/baser-core/src/Service/BcDatabaseService.php @@ -411,14 +411,18 @@ protected function _loadDefaultDataPattern($pattern, $theme, $plugin = 'BaserCor if (!$this->loadCsv(['path' => $file, 'encoding' => 'auto', 'dbConfigKeyName' => $dbConfigKeyName])) { $this->log(sprintf(__d('baser_core', '%s の読み込みに失敗。'), $file)); $result = false; - } else { - break; } } catch(\Throwable $e) { throw $e; } } } + try { + $pluginClass = Plugin::getCollection()->get($plugin); + if(method_exists($pluginClass, 'updateDefaultData')) { + $pluginClass->updateDefaultData(); + } + } catch (\Throwable) {} return $result; } diff --git a/plugins/baser-core/src/Utility/BcUtil.php b/plugins/baser-core/src/Utility/BcUtil.php index 717d554bdc..6005136370 100644 --- a/plugins/baser-core/src/Utility/BcUtil.php +++ b/plugins/baser-core/src/Utility/BcUtil.php @@ -1097,7 +1097,7 @@ public static function getContentsItem(): array */ public static function isInstalled() { - return (bool)Configure::read('BcRequest.isInstalled'); + return (bool)Configure::read('BcEnv.isInstalled'); } /** @@ -1463,6 +1463,8 @@ public static function isWindows() * * @param mixed $url * @return mixed + * @checked + * @noTodo */ public static function addSessionId($url, $force = false) { @@ -1474,12 +1476,10 @@ public static function addSessionId($url, $force = false) return $url; } - $site = null; - if (!Configure::read('BcRequest.isUpdater')) { - $currentUrl = \Cake\Routing\Router::getRequest()->getPath(); - $sites = \Cake\ORM\TableRegistry::getTableLocator()->get('BaserCore.Sites'); - $site = $sites->findByUrl($currentUrl); - } + $currentUrl = \Cake\Routing\Router::getRequest()->getPath(); + $sites = \Cake\ORM\TableRegistry::getTableLocator()->get('BaserCore.Sites'); + $site = $sites->findByUrl($currentUrl); + // use_trans_sid が有効になっている場合、2重で付加されてしまう if ($site && $site->device == 'mobile' && Configure::read('BcAgent.mobile.sessionId') && (!ini_get('session.use_trans_sid') || $force)) { if (is_array($url)) { diff --git a/plugins/baser-core/src/View/Helper/BcToolbarHelper.php b/plugins/baser-core/src/View/Helper/BcToolbarHelper.php index da927acbfe..9ad20fbdfe 100644 --- a/plugins/baser-core/src/View/Helper/BcToolbarHelper.php +++ b/plugins/baser-core/src/View/Helper/BcToolbarHelper.php @@ -130,7 +130,6 @@ public function isAvailableLogin(): bool if (BcUtil::loginUser()) return false; if ($this->_View->getName() === 'Installations') return false; if ($this->isLoginUrl()) return false; - if (Configure::read('BcRequest.isUpdater')) return false; return true; } @@ -286,11 +285,14 @@ public function isLoginUrl(): bool */ public function getLogoType(): string { - if ($this->_View->getName() === 'Installations') { + if ($this->getView()->getName() === 'Installations') { return 'install'; - } elseif (Configure::read('BcRequest.isUpdater')) { + } elseif ($this->getView()->getRequest()->getParam('controller') === 'Plugins' + && $this->getView()->getRequest()->getParam('action') === 'update' + && empty($this->getView()->getRequest()->getParam('pass')) + ) { return 'update'; - } elseif ($this->_View->getRequest()->getParam('prefix') === "Admin" || $this->isLoginUrl()) { + } elseif ($this->getView()->getRequest()->getParam('prefix') === "Admin" || $this->isLoginUrl()) { return 'normal'; } else { if ($this->BcAuth->isCurrentUserAdminAvailable()) { diff --git a/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php index c1138c8cfb..7b4061b7c4 100644 --- a/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php @@ -91,11 +91,9 @@ public function tearDown(): void */ public function testBeforeFilter() { - Configure::write('BcRequest.isUpdater', true); $event = new Event('Controller.beforeFilter', $this->PluginsController); $this->PluginsController->beforeFilter($event); $this->assertEquals($this->PluginsController->FormProtection->getConfig('unlockedActions'), ['reset_db', 'update_sort', 'batch']); - $this->assertEquals(['update'], $this->PluginsController->Authentication->getUnauthenticatedActions()); } /** diff --git a/plugins/baser-core/tests/TestCase/Middleware/BcRequestFilterMiddlewareTest.php b/plugins/baser-core/tests/TestCase/Middleware/BcRequestFilterMiddlewareTest.php index 6f9e061c06..c0f5be372b 100644 --- a/plugins/baser-core/tests/TestCase/Middleware/BcRequestFilterMiddlewareTest.php +++ b/plugins/baser-core/tests/TestCase/Middleware/BcRequestFilterMiddlewareTest.php @@ -63,9 +63,6 @@ public function testProcess(): void $this->loadFixtureScenario(MultiSiteScenario::class); $this->_response = $this->BcRequestFilterMiddleware->process($this->getRequest(), $this->Application); $this->assertResponseOk(); - $url = '/img/test.png'; - $this->_response = $this->BcRequestFilterMiddleware->process($this->getRequest($url), $this->Application); - $this->assertTrue(Configure::read('BcRequest.asset')); } /** @@ -156,44 +153,6 @@ public static function isAdminDataProvider() ]; } - /** - * アセットのURLかどうかを判定 - * - * @param bool $expect 期待値 - * @param string $url URL文字列 - * @return void - * @dataProvider isAssetDataProvider - */ - public function testIsAsset($expect, $url) - { - $this->assertEquals($expect, $this->BcRequestFilterMiddleware->isAsset($this->getRequest($url))); - } - - /** - * isAsset用データプロバイダ - * - * @return array - */ - public static function isAssetDataProvider() - { - return [ - [false, '/'], - [false, '/about'], - [false, '/img/test.html'], - [false, '/js/test.php'], - [false, '/css/file.cgi'], - [true, '/img/image.png'], - [true, '/js/startup.js'], - [true, '/css/main.css'], - [false, '/theme/example_theme/img/test.html'], - [false, '/theme/example_theme/js/test.php'], - [false, '/theme/example_theme/css/file.cgi'], - [true, '/theme/example_theme/img/image.png'], - [true, '/theme/example_theme/js/startup.js'], - [true, '/theme/example_theme/css/main.css'] - ]; - } - /** * インストール用のURLかどうかを判定 * diff --git a/plugins/baser-core/tests/TestCase/PluginTest.php b/plugins/baser-core/tests/TestCase/PluginTest.php index a577970688..cf788e117c 100644 --- a/plugins/baser-core/tests/TestCase/PluginTest.php +++ b/plugins/baser-core/tests/TestCase/PluginTest.php @@ -12,6 +12,7 @@ namespace BaserCore\Test\TestCase; use App\Application; +use Authentication\Middleware\AuthenticationMiddleware; use BaserCore\BaserCorePlugin; use BaserCore\Service\SiteConfigsServiceInterface; use BaserCore\Test\Scenario\ContentsScenario; @@ -29,6 +30,7 @@ use Cake\Event\EventManager; use Cake\Http\Middleware\CsrfProtectionMiddleware; use Cake\Http\MiddlewareQueue; +use Cake\Routing\Middleware\RoutingMiddleware; use Cake\Routing\Router; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -173,9 +175,10 @@ public function testMiddleware(): void { $middleware = new MiddlewareQueue(); $middleware->add(CsrfProtectionMiddleware::class); + $middleware->add(RoutingMiddleware::class); $middlewareQueue = $this->Plugin->middleware($middleware); - $this->assertInstanceOf(BcRequestFilterMiddleware::class, $middlewareQueue->current()); - $this->assertEquals(6, $middlewareQueue->count()); + $this->assertInstanceOf(AuthenticationMiddleware::class, $middlewareQueue->current()); + $this->assertEquals(7, $middlewareQueue->count()); } /** diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcToolbarHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcToolbarHelperTest.php index 065446d46c..485fd117db 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcToolbarHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcToolbarHelperTest.php @@ -138,10 +138,6 @@ public function testIsAvailableLogin() // インストーラーの場合 $toolbar = new BcToolbarHelper(new View(null, null, null, ['name' => 'Installations'])); $this->assertFalse($toolbar->isAvailableLogin()); - // アップデーターの場合 - Configure::write('BcRequest.isUpdater', true); - $this->assertFalse($this->BcToolbar->isAvailableLogin()); - Configure::write('BcRequest.isUpdater', false); // ログイン画面の場合 $toolbar = new BcToolbarHelper(new View($this->getRequest('/baser/admin/baser-core/users/login'))); $this->assertFalse($toolbar->isAvailableLogin()); @@ -280,9 +276,8 @@ public function testGetLogoType() $bcToolbar = new BcToolbarHelper(new View($this->getRequest('/baser/admin/baser-core/users/login'))); $this->assertEquals('normal', $bcToolbar->getLogoType()); // アップデーター - Configure::write('BcRequest.isUpdater', true); + $bcToolbar->getView()->setRequest($this->getRequest('/baser/admin/baser-core/plugins/update')); $this->assertEquals('update', $bcToolbar->getLogoType()); - Configure::write('BcRequest.isUpdater', false); // インストーラー $bcToolbar = new BcToolbarHelper(new View(null, null, null, ['name' => 'Installations'])); $this->assertEquals('install', $bcToolbar->getLogoType()); @@ -302,14 +297,13 @@ public function testGetLogoLink() $bcToolbar = new BcToolbarHelper(new View($this->getRequest('/baser/admin/baser-core/users/login'))); $this->assertEquals('https://localhost/', $bcToolbar->getLogoLink()); // アップデーター - Configure::write('BcRequest.isUpdater', true); + $bcToolbar->getView()->setRequest($this->getRequest('/baser/admin/baser-core/plugins/update')); $this->assertEquals('https://baserproject.github.io/5/operation/update', $bcToolbar->getLogoLink()); - Configure::write('BcRequest.isUpdater', false); // インストーラー - Configure::write('BcRequest.isInstalled', false); + Configure::write('BcEnv.isInstalled', false); $bcToolbar = new BcToolbarHelper(new View(null, null, null, ['name' => 'Installations'])); $this->assertEquals('https://baserproject.github.io/5/introduce/', $bcToolbar->getLogoLink()); - Configure::write('BcRequest.isInstalled', true); + Configure::write('BcEnv.isInstalled', true); } /** @@ -326,9 +320,8 @@ public function testGetLogoText() $bcToolbar = new BcToolbarHelper(new View($this->getRequest('/baser/admin/baser-core/users/login'))); $this->assertEquals('サイト表示', $bcToolbar->getLogoText()); // アップデーター - Configure::write('BcRequest.isUpdater', true); + $bcToolbar->getView()->setRequest($this->getRequest('/baser/admin/baser-core/plugins/update')); $this->assertEquals('アップデートマニュアル', $bcToolbar->getLogoText()); - Configure::write('BcRequest.isUpdater', false); // インストーラー $bcToolbar = new BcToolbarHelper(new View(null, null, null, ['name' => 'Installations'])); $this->assertEquals('インストールマニュアル', $bcToolbar->getLogoText()); @@ -357,11 +350,10 @@ public function testGetLogoLinkOptions() $this->assertTrue(in_array('bca-toolbar__logo-link', $options)); // アップデーター - Configure::write('BcRequest.isUpdater', true); + $bcToolbar->getView()->setRequest($this->getRequest('/baser/admin/baser-core/plugins/update')); $options = $bcToolbar->getLogoLinkOptions(); $this->assertTrue(in_array('bca-toolbar__logo-link', $options)); $this->assertTrue(in_array('_blank', $options)); - Configure::write('BcRequest.isUpdater', false); // インストーラー $bcToolbar = new BcToolbarHelper(new View(null, null, null, ['name' => 'Installations'])); diff --git a/plugins/bc-blog/src/BcBlogPlugin.php b/plugins/bc-blog/src/BcBlogPlugin.php index b080ce5bd8..6bd91ac58c 100755 --- a/plugins/bc-blog/src/BcBlogPlugin.php +++ b/plugins/bc-blog/src/BcBlogPlugin.php @@ -16,6 +16,7 @@ use BaserCore\Model\Table\SitesTable; use BaserCore\Utility\BcContainerTrait; use BcBlog\ServiceProvider\BcBlogServiceProvider; +use Cake\Core\Configure; use Cake\Core\ContainerInterface; use BaserCore\Annotation\NoTodo; use BaserCore\Annotation\Checked; @@ -48,12 +49,23 @@ public function install($options = []) : bool { $result = parent::install($options); // ブログ記事の投稿日を更新 - if(empty($options['db_init'])) { + if(Configure::read('BcEnv.isInstalled') && empty($options['db_init'])) { $this->updateDateNow('BcBlog.BlogPosts', ['posted'], [], $options); } return $result; } + /** + * 初期データ読み込み時の更新処理 + * @param array $options + * @return void + */ + public function updateDefaultData($options = []) : void + { + // ブログ記事の投稿日を更新 + $this->updateDateNow('BcBlog.BlogPosts', ['posted'], [], $options); + } + /** * プラグインをアンインストールする * diff --git a/plugins/bc-custom-content/src/BcCustomContentPlugin.php b/plugins/bc-custom-content/src/BcCustomContentPlugin.php index 9a85e8f41d..fd6a5a1027 100644 --- a/plugins/bc-custom-content/src/BcCustomContentPlugin.php +++ b/plugins/bc-custom-content/src/BcCustomContentPlugin.php @@ -47,18 +47,31 @@ public function install($options = []): bool 'connection' => 'default' ], $options); $result = parent::install($options); - $table = TableRegistry::getTableLocator()->get('BcCustomContent.CustomEntries', ['connectionName' => $options['connection']]); - $table->setUp(1); - $this->updateDateNow('BcCustomContent.CustomEntries', ['published'], [], $options); + if(Configure::read('BcEnv.isInstalled') && empty($options['db_init'])) { + $table = TableRegistry::getTableLocator()->get('BcCustomContent.CustomEntries', ['connectionName' => $options['connection']]); + $table->setUp(1); + $this->updateDateNow('BcCustomContent.CustomEntries', ['published'], [], $options); + } return $result; } + /** + * 初期データ読み込み時の更新処理 + * @param array $options + * @return void + */ + public function updateDefaultData($options = []) : void + { + // エントリーの公開日を更新 + $this->updateDateNow('BcCustomContent.CustomEntries', ['published'], [], $options); + } + /** * services * @param ContainerInterface $container * @checked * @noTodo - * @unitTest + * @unitTest */ public function services(ContainerInterface $container): void { @@ -81,7 +94,9 @@ public function bootstrap(PluginApplicationInterface $app): void /** * カスタムコンテンツコアのプラグインをロードする * + * @return void * @checked + * @noTodo */ public function loadPlugin(): void { @@ -96,20 +111,13 @@ public function loadPlugin(): void $files = $Folder->getFolders(); if (empty($files)) return; - if (Configure::read('BcRequest.asset')) { - // TODO ucmitz 検証要 - foreach($files as $pluginName) { - BcUtil::includePluginClass($pluginName); - } - } else { - foreach($files as $pluginName) { - // 設定ファイルを読み込む - if (!BcUtil::includePluginClass($pluginName)) continue; - $pluginCollection = CakePlugin::getCollection(); - $plugin = $pluginCollection->create($pluginName); - $pluginCollection->add($plugin); - BcEvent::registerPluginEvent($pluginName); - } + foreach($files as $pluginName) { + // 設定ファイルを読み込む + if (!BcUtil::includePluginClass($pluginName)) continue; + $pluginCollection = CakePlugin::getCollection(); + $plugin = $pluginCollection->create($pluginName); + $pluginCollection->add($plugin); + BcEvent::registerPluginEvent($pluginName); } } diff --git a/plugins/bc-installer/src/Service/InstallationsService.php b/plugins/bc-installer/src/Service/InstallationsService.php index 4322ad78e5..512b89c1dc 100644 --- a/plugins/bc-installer/src/Service/InstallationsService.php +++ b/plugins/bc-installer/src/Service/InstallationsService.php @@ -358,61 +358,10 @@ public function setSiteName(string $name) */ public function executeDefaultUpdates(): bool { - $result = true; - if (!$this->_updateContents()) { - $this->log(__d('baser_core', 'コンテンツの更新に失敗しました。')); - $result = false; - } - if (!$this->_updateBlogPosts()) { - $this->log(__d('baser_core', 'ブログ記事の更新に失敗しました。')); - $result = false; - } /** @var SearchIndexesServiceInterface $searchIndexesService */ $searchIndexesService = $this->getService(SearchIndexesServiceInterface::class); $searchIndexesService->reconstruct(); - return $result; - } - - /** - * コンテンツの作成日を更新する - * - * @return bool - * @checked - * @noTodo - */ - protected function _updateContents(): bool - { - $contentsTable = TableRegistry::getTableLocator()->get('BaserCore.Contents'); - $contents = $contentsTable->find()->all(); - $result = true; - foreach($contents as $content) { - $content->created_date = new \Cake\I18n\DateTime(); - if (!$contentsTable->save($content)) { - $result = false; - } - } - return $result; - } - - /** - * コンテンツの作成日を更新する - * - * @return bool - * @checked - * @noTodo - */ - protected function _updateBlogPosts(): bool - { - $table = TableRegistry::getTableLocator()->get('BcBlog.BlogPosts'); - $entities = $table->find()->all(); - $result = true; - foreach($entities as $entity) { - $entity->posted = new \Cake\I18n\DateTime(); - if (!$table->save($entity)) { - $result = false; - } - } - return $result; + return true; } /** diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 6696c1c91c..d1efe9038a 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -185,14 +185,6 @@ public function testExecuteDefaultUpdates() $this->assertTrue($result, 'データベースのデータに初期更新に失敗しました'); } - /** - * test _updateContents - */ - public function test_updateContents() - { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - } - /** * test installCorePlugin */ diff --git a/plugins/bc-widget-area/tests/TestCase/Service/Admin/WidgetAreasAdminServiceTest.php b/plugins/bc-widget-area/tests/TestCase/Service/Admin/WidgetAreasAdminServiceTest.php index d0073bc43f..d8ba33245a 100644 --- a/plugins/bc-widget-area/tests/TestCase/Service/Admin/WidgetAreasAdminServiceTest.php +++ b/plugins/bc-widget-area/tests/TestCase/Service/Admin/WidgetAreasAdminServiceTest.php @@ -74,7 +74,7 @@ public function test_getWidgetInfos() 'paths' => ['/var/www/html/plugins/bc-admin-third/templates/Admin/element/widget'] ], $result[0]); //正常系実行 - Configure::write('BcRequest.isInstalled', true); + Configure::write('BcEnv.isInstalled', true); $result = $this->execPrivateMethod($this->WidgetAreasAdminService, 'getWidgetInfos'); $this->assertCount(1, $result); $this->assertEquals('BaserCore', $result[0]['plugin']);