Skip to content

Commit

Permalink
CakePHP45にアップグレード、非推奨を調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Oct 27, 2023
1 parent 34e6004 commit c44995b
Show file tree
Hide file tree
Showing 37 changed files with 120 additions and 111 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ext-mbstring": "*",
"ext-pdo": "*",
"cakephp/authentication": "^2.9",
"cakephp/cakephp": "4.4.*",
"cakephp/cakephp": "^4.5",
"cakephp/migrations": "^3.2",
"doctrine/annotations": "^1.12",
"firebase/php-jwt": "6.1.0",
Expand Down
51 changes: 26 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified logs/.gitkeep
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion plugins/baser-core/config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* エラー構成
*/
'Error' => [
'errorLevel' => E_ALL & ~E_USER_DEPRECATED,
'errorLevel' => E_ALL,
'exceptionRenderer' => BcExceptionRenderer::class,
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function redirectIfIsNotSameSite()
{
if (Configure::read('BcEnv.cmsUrl')) {
$siteUrl = Configure::read('BcEnv.cmsUrl');
} elseif ($this->getRequest()->is('ssl')) {
} elseif ($this->getRequest()->is('https')) {
$siteUrl = Configure::read('BcEnv.sslUrl');
} else {
$siteUrl = Configure::read('BcEnv.siteUrl');
Expand Down
4 changes: 3 additions & 1 deletion plugins/baser-core/src/Event/BcModelEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace BaserCore\Event;

use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\Event\EventInterface;
use Cake\Event\EventListenerInterface;
use BaserCore\Annotation\UnitTest;
use BaserCore\Annotation\NoTodo;
Expand Down Expand Up @@ -187,7 +189,7 @@ public function afterSave(Event $event): void
* @noTodo
* @unitTest
*/
public function beforeDelete(Event $event): bool
public function beforeDelete(EventInterface $event, EntityInterface $entity, \ArrayObject $options): bool
{
if (!method_exists($event->getSubject(), 'dispatchLayerEvent')) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function afterSave(EventInterface $event, EntityInterface $entity)
* @noTodo
* @unitTest
*/
public function beforeDelete(EventInterface $event, EntityInterface $entity)
public function beforeDelete(EventInterface $event, EntityInterface $entity, \ArrayObject $options)
{
$oldEntity = $this->getOldEntity($entity->id);
$this->BcFileUploader[$this->table()->getAlias()]->deleteFiles($oldEntity, $entity, true);
Expand Down
4 changes: 2 additions & 2 deletions plugins/baser-core/src/Model/Table/ContentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ public function createUrl($id)
// =========================================================================================================
$connection = ConnectionManager::get('default');
$content = $connection
->newQuery()
->selectQuery()
->select(['lft', 'rght'])
->from($prefix . 'contents')
->where(['id' => $id, 'deleted_date IS' => null])
Expand All @@ -882,7 +882,7 @@ public function createUrl($id)
return false;
}
$parents = $connection
->newQuery()
->selectQuery()
->select(['name', 'plugin', 'type'])
->from($prefix . 'contents')
->where(['lft <=' => $content['lft'], 'rght >=' => $content['rght'], 'deleted_date IS' => null])
Expand Down
8 changes: 3 additions & 5 deletions plugins/baser-core/src/Model/Table/UserGroupsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use BaserCore\Model\Entity\UserGroup;
use Cake\Core\Configure;
use Cake\Event\EventInterface;
use Cake\ORM\Association\BelongsToMany;
use Cake\ORM\Behavior\TimestampBehavior as TimestampBehaviorAlias;
use Cake\Datasource\{EntityInterface, ResultSetInterface as ResultSetInterfaceAlias};
Expand Down Expand Up @@ -178,7 +179,7 @@ public function copy($id)
* @param boolean $cascade
* @return boolean
*/
public function beforeDelete($cascade = true)
public function beforeDelete(EventInterface $event, EntityInterface $entity, \ArrayObject $options)
{
if (!empty($this->data['UserGroup']['id'])) {
$id = $this->data['UserGroup']['id'];
Expand All @@ -188,13 +189,10 @@ public function beforeDelete($cascade = true)
foreach($datas as $data) {
$data['User']['user_group_id'] = Configure::read('BcApp.adminGroupId');
$this->User->set($data);
if (!$this->User->save()) {
$cascade = false;
}
$this->User->save();
}
}
}
return $cascade;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function afterMarshal(Event $event, User $user, ArrayObject $data, ArrayO
* @noTodo
* @unitTest
*/
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options)
public function afterSave(\Cake\Event\EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
// ユーザデータが変更された場合は自動ログインのデータを削除する
$loginStores = TableRegistry::getTableLocator()->get('BaserCore.LoginStores');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getViewVarsForInfo(): array
$driver = $db->config()['driver'];
$sqlMode = '';
if($driver === Mysql::class) {
$sqlMode = $db->query('SELECT @@global.sql_mode;')->fetch()[0];
$sqlMode = $db->execute('SELECT @@global.sql_mode;')->fetch()[0];
}
return [
'datasource' => $this->_getDriver(),
Expand Down
12 changes: 6 additions & 6 deletions plugins/baser-core/src/Service/BcDatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public function writeCsv($table, $options): bool
break;
}

$query = $db->query($sql);
$query = $db->execute($sql);
$records = $query->fetchAll('assoc');

$fp = fopen($options['path'], 'w');
Expand Down Expand Up @@ -1212,7 +1212,7 @@ public function connectDb(array $config, $name = 'default')
}
}
$db = ConnectionManager::get($name);
$db->connect();
$db->getDriver()->connect();
return $db;
}

Expand Down Expand Up @@ -1404,7 +1404,7 @@ public function testConnectDb($config)
/* @var Connection $db */
$db = $this->connectDb($config);

if (!$db->isConnected()) {
if (!$db->getDriver()->isConnected()) {
throw new BcException(__d('baser_core', "データベースへの接続でエラーが発生しました。データベース設定を見直してください。"));
}

Expand All @@ -1419,7 +1419,7 @@ public function testConnectDb($config)
break;
case 'Cake\Database\Driver\Postgres' :
// TODO ucmitz 未検証
$result = $db->query("SELECT version() as version")->fetch();
$result = $db->execute("SELECT version() as version")->fetch();
[, $version] = explode(" ", $result[0]);
if (version_compare(trim($version), Configure::read('BcRequire.PostgreSQLVersion')) == -1) {
throw new BcException(sprintf(__d('baser_core', 'データベースのバージョンが %s 以上か確認してください。'), Configure::read('BcRequire.PostgreSQLVersion')));
Expand Down Expand Up @@ -1466,8 +1466,8 @@ public function constructionTable(string $plugin, string $dbConfigKeyName = 'def
if (!$dbConfig) $dbConfig = ConnectionManager::getConfig($dbConfigKeyName);
$datasource = strtolower(str_replace('Cake\\Database\\Driver\\', '', $dbConfig['driver']));
if ($datasource === 'sqlite') {
$db->connect();
} elseif (!$db->isConnected()) {
$db->getDriver()->connect();
} elseif (!$db->getDriver()->isConnected()) {
return false;
}
return $this->migrate($plugin, $dbConfigKeyName);
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Utility/BcUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ public static function topLevelUrl($lastSlash = true)
}
$request = Router::getRequest();
$protocol = 'http://';
if (!empty($request) && $request->is('ssl')) {
if (!empty($request) && $request->is('https')) {
$protocol = 'https://';
}
$host = Configure::read('BcEnv.host');
Expand Down
18 changes: 9 additions & 9 deletions plugins/baser-core/src/View/AppView.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class AppView extends View
public function initialize(): void
{
parent::initialize();
$this->loadHelper('BaserCore.BcTime');
$this->loadHelper('BaserCore.BcForm', ['templates' => 'BaserCore.bc_form']);
$this->loadHelper('BaserCore.BcAdmin');
$this->loadHelper('BaserCore.BcContents');
$this->loadHelper('BaserCore.BcPage');
$this->loadHelper('BaserCore.BcBaser');
$this->loadHelper('BaserCore.BcUpload');
$this->loadHelper('BaserCore.BcToolbar');
$this->loadHelper('Paginator');
$this->addHelper('BaserCore.BcTime');
$this->addHelper('BaserCore.BcForm', ['templates' => 'BaserCore.bc_form']);
$this->addHelper('BaserCore.BcAdmin');
$this->addHelper('BaserCore.BcContents');
$this->addHelper('BaserCore.BcPage');
$this->addHelper('BaserCore.BcBaser');
$this->addHelper('BaserCore.BcUpload');
$this->addHelper('BaserCore.BcToolbar');
$this->addHelper('Paginator');
$this->assign('title', $this->get('title'));
}

Expand Down
18 changes: 9 additions & 9 deletions plugins/baser-core/src/View/BcAdminAppView.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ class BcAdminAppView extends AppView
public function initialize(): void
{
parent::initialize();
$this->loadHelper('BaserCore.BcAdminForm', ['templates' => 'BaserCore.bc_form']);
$this->loadHelper('BaserCore.BcAuth');
$this->loadHelper('BaserCore.BcText');
$this->loadHelper('BaserCore.BcContents');
$this->loadHelper('BaserCore.BcListTable');
$this->loadHelper('BaserCore.BcHtml');
$this->loadHelper('BaserCore.BcSiteConfig');
$this->loadHelper('BaserCore.BcSearchBox');
$this->loadHelper('BaserCore.BcFormTable');
$this->addHelper('BaserCore.BcAdminForm', ['templates' => 'BaserCore.bc_form']);
$this->addHelper('BaserCore.BcAuth');
$this->addHelper('BaserCore.BcText');
$this->addHelper('BaserCore.BcContents');
$this->addHelper('BaserCore.BcListTable');
$this->addHelper('BaserCore.BcHtml');
$this->addHelper('BaserCore.BcSiteConfig');
$this->addHelper('BaserCore.BcSearchBox');
$this->addHelper('BaserCore.BcFormTable');
if (!$this->get('title')) {
$this->set('title', 'Undefined');
}
Expand Down
Loading

0 comments on commit c44995b

Please sign in to comment.