diff --git a/README.md b/README.md index 41ce9211..363e7c89 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ framework are exposed. ## Repository Management -We use Github issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages. +We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages. We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss FEATURE REQUESTS. diff --git a/app/Config/CURLRequest.php b/app/Config/CURLRequest.php new file mode 100644 index 00000000..b4c8e5c4 --- /dev/null +++ b/app/Config/CURLRequest.php @@ -0,0 +1,22 @@ + 'CodeIgniter\Commands\Generators\Views\command.tpl.php', + 'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php', 'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php', 'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php', 'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php', diff --git a/app/Config/Kint.php b/app/Config/Kint.php index 4b52422a..b1016ed5 100644 --- a/app/Config/Kint.php +++ b/app/Config/Kint.php @@ -24,26 +24,19 @@ class Kint extends BaseConfig */ public $plugins; - - public $maxDepth = 6; - + public $maxDepth = 6; public $displayCalledFrom = true; - - public $expanded = false; + public $expanded = false; /* |-------------------------------------------------------------------------- | RichRenderer Settings |-------------------------------------------------------------------------- */ - public $richTheme = 'aante-light.css'; - + public $richTheme = 'aante-light.css'; public $richFolder = false; - - public $richSort = Renderer::SORT_FULL; - + public $richSort = Renderer::SORT_FULL; public $richObjectPlugins; - public $richTabPlugins; /* @@ -51,11 +44,8 @@ class Kint extends BaseConfig | CLI Settings |-------------------------------------------------------------------------- */ - public $cliColors = true; - - public $cliForceUTF8 = false; - + public $cliColors = true; + public $cliForceUTF8 = false; public $cliDetectWidth = true; - - public $cliMinWidth = 40; + public $cliMinWidth = 40; } diff --git a/app/Config/Publisher.php b/app/Config/Publisher.php new file mode 100644 index 00000000..f3768bc5 --- /dev/null +++ b/app/Config/Publisher.php @@ -0,0 +1,28 @@ + + */ + public $restrictions = [ + ROOTPATH => '*', + FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i', + ]; +} diff --git a/app/Config/Security.php b/app/Config/Security.php index c4cf7a25..563cf2f3 100644 --- a/app/Config/Security.php +++ b/app/Config/Security.php @@ -6,12 +6,23 @@ class Security extends BaseConfig { + /** + * -------------------------------------------------------------------------- + * CSRF Protection Method + * -------------------------------------------------------------------------- + * + * Protection Method for Cross Site Request Forgery protection. + * + * @var string 'cookie' or 'session' + */ + public $csrfProtection = 'cookie'; + /** * -------------------------------------------------------------------------- * CSRF Token Name * -------------------------------------------------------------------------- * - * Token name for Cross Site Request Forgery protection cookie. + * Token name for Cross Site Request Forgery protection. * * @var string */ @@ -22,7 +33,7 @@ class Security extends BaseConfig * CSRF Header Name * -------------------------------------------------------------------------- * - * Token name for Cross Site Request Forgery protection cookie. + * Header name for Cross Site Request Forgery protection. * * @var string */ @@ -33,7 +44,7 @@ class Security extends BaseConfig * CSRF Cookie Name * -------------------------------------------------------------------------- * - * Cookie name for Cross Site Request Forgery protection cookie. + * Cookie name for Cross Site Request Forgery protection. * * @var string */ @@ -57,7 +68,7 @@ class Security extends BaseConfig * CSRF Regenerate * -------------------------------------------------------------------------- * - * Regenerate CSRF Token on every request. + * Regenerate CSRF Token on every submission. * * @var bool */ diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index 7050aa91..9ee2e427 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -163,7 +163,7 @@ color: rgba(200, 200, 200, 1); padding: .25rem 1.75rem; } - @media (max-width: 559px) { + @media (max-width: 629px) { header ul { padding: 0; } diff --git a/builds b/builds index 268e7a81..0b10a150 100755 --- a/builds +++ b/builds @@ -15,149 +15,111 @@ define('GITHUB_URL', 'https://github.com/codeigniter4/codeigniter4'); */ // Determine the requested stability -if (empty($argv[1]) || ! in_array($argv[1], ['release', 'development'])) -{ - echo 'Usage: php builds [release|development]' . PHP_EOL; - exit; +if (empty($argv[1]) || ! in_array($argv[1], ['release', 'development'], true)) { + echo 'Usage: php builds [release|development]' . PHP_EOL; + + exit; } -$dev = $argv[1] == 'development'; +$dev = $argv[1] === 'development'; + $modified = []; -/* Locate each file and update it for the requested stability */ +// Locate each file and update it for the requested stability -// Composer.json $file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.json'; -if (is_file($file)) -{ - // Make sure we can read it - if ($contents = file_get_contents($file)) - { - if ($array = json_decode($contents, true)) - { - // Development - if ($dev) - { - // Set 'minimum-stability' - $array['minimum-stability'] = 'dev'; - $array['prefer-stable'] = true; - - // Make sure the repo is configured - if (! isset($array['repositories'])) - { - $array['repositories'] = []; - } - - // Check for the CodeIgniter repo - $found = false; - foreach ($array['repositories'] as $repository) - { - if ($repository['url'] == GITHUB_URL) - { - $found = true; - break; - } - } - - // Add the repo if it was not found - if (! $found) - { - $array['repositories'][] = [ - 'type' => 'vcs', - 'url' => GITHUB_URL, - ]; - } - - // Define the "require" - $array['require']['codeigniter4/codeigniter4'] = 'dev-develop'; - unset($array['require']['codeigniter4/framework']); - } - - // Release - else - { - // Clear 'minimum-stability' - unset($array['minimum-stability']); - - // If the repo is configured then clear it - if (isset($array['repositories'])) - { - // Check for the CodeIgniter repo - foreach ($array['repositories'] as $i => $repository) - { - if ($repository['url'] == GITHUB_URL) - { - unset($array['repositories'][$i]); - break; - } - } - if (empty($array['repositories'])) - { - unset($array['repositories']); - } - } - - // Define the "require" - $array['require']['codeigniter4/framework'] = LATEST_RELEASE; - unset($array['require']['codeigniter4/codeigniter4']); - } - - // Write out a new composer.json - file_put_contents($file, json_encode($array, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES) . PHP_EOL); - $modified[] = $file; - } - else - { - echo 'Warning: Unable to decode composer.json! Skipping...' . PHP_EOL; - } - } - else - { - echo 'Warning: Unable to read composer.json! Skipping...' . PHP_EOL; - } +if (is_file($file)) { + $contents = file_get_contents($file); + + if ((string) $contents !== '') { + $array = json_decode($contents, true); + + if (is_array($array)) { + if ($dev) { + $array['minimum-stability'] = 'dev'; + $array['prefer-stable'] = true; + $array['repositories'] = $array['repositories'] ?? []; + + $found = false; + + foreach ($array['repositories'] as $repository) { + if ($repository['url'] === GITHUB_URL) { + $found = true; + break; + } + } + + if (! $found) { + $array['repositories'][] = [ + 'type' => 'vcs', + 'url' => GITHUB_URL, + ]; + } + + $array['require']['codeigniter4/codeigniter4'] = 'dev-develop'; + unset($array['require']['codeigniter4/framework']); + } else { + unset($array['minimum-stability']); + + if (isset($array['repositories'])) { + foreach ($array['repositories'] as $i => $repository) { + if ($repository['url'] === GITHUB_URL) { + unset($array['repositories'][$i]); + break; + } + } + + if (empty($array['repositories'])) { + unset($array['repositories']); + } + } + + $array['require']['codeigniter4/framework'] = LATEST_RELEASE; + unset($array['require']['codeigniter4/codeigniter4']); + } + + file_put_contents($file, json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL); + + $modified[] = $file; + } else { + echo 'Warning: Unable to decode composer.json! Skipping...' . PHP_EOL; + } + } else { + echo 'Warning: Unable to read composer.json! Skipping...' . PHP_EOL; + } } -// Paths config and PHPUnit XMLs $files = [ - __DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php', - __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist', - __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml', + __DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php', + __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist', + __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml', ]; -foreach ($files as $file) -{ - if (is_file($file)) - { - $contents = file_get_contents($file); - - // Development - if ($dev) - { - $contents = str_replace('vendor/codeigniter4/framework', 'vendor/codeigniter4/codeigniter4', $contents); - } - - // Release - else - { - $contents = str_replace('vendor/codeigniter4/codeigniter4', 'vendor/codeigniter4/framework', $contents); - } - - file_put_contents($file, $contents); - $modified[] = $file; - } -} +foreach ($files as $file) { + if (is_file($file)) { + $contents = file_get_contents($file); + + if ($dev) { + $contents = str_replace('vendor/codeigniter4/framework', 'vendor/codeigniter4/codeigniter4', $contents); + } else { + $contents = str_replace('vendor/codeigniter4/codeigniter4', 'vendor/codeigniter4/framework', $contents); + } -if (empty($modified)) -{ - echo 'No files modified' . PHP_EOL; + file_put_contents($file, $contents); + + $modified[] = $file; + } } -else -{ - echo 'The following files were modified:' . PHP_EOL; - foreach ($modified as $file) - { - echo " * {$file}" . PHP_EOL; - } - echo 'Run `composer update` to sync changes with your vendor folder' . PHP_EOL; + +if ($modified === []) { + echo 'No files modified.' . PHP_EOL; +} else { + echo 'The following files were modified:' . PHP_EOL; + + foreach ($modified as $file) { + echo " * {$file}" . PHP_EOL; + } + + echo 'Run `composer update` to sync changes with your vendor folder.' . PHP_EOL; } diff --git a/env b/env index 38eabf20..6e30e34b 100644 --- a/env +++ b/env @@ -110,6 +110,7 @@ # SECURITY #-------------------------------------------------------------------- +# security.csrfProtection = 'cookie' # security.tokenName = 'csrf_token_name' # security.headerName = 'X-CSRF-TOKEN' # security.cookieName = 'csrf_cookie_name' @@ -123,3 +124,9 @@ #-------------------------------------------------------------------- # logger.threshold = 4 + +#-------------------------------------------------------------------- +# CURLRequest +#-------------------------------------------------------------------- + +# curlrequest.shareOptions = true diff --git a/tests/_support/DatabaseTestCase.php b/tests/_support/DatabaseTestCase.php deleted file mode 100644 index fd067a58..00000000 --- a/tests/_support/DatabaseTestCase.php +++ /dev/null @@ -1,61 +0,0 @@ -mockSession(); - } - - /** - * Pre-loads the mock session driver into $this->session. - * - * @var string - */ - protected function mockSession() - { - $config = config('App'); - $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config); - \Config\Services::injectMock('session', $this->session); - } -} diff --git a/tests/database/ExampleDatabaseTest.php b/tests/database/ExampleDatabaseTest.php index 203b1261..5d13836f 100644 --- a/tests/database/ExampleDatabaseTest.php +++ b/tests/database/ExampleDatabaseTest.php @@ -1,18 +1,15 @@ session->set('logged_in', 123); - - $value = $this->session->get('logged_in'); - - $this->assertSame(123, $value); + $this->assertSame(123, $this->session->get('logged_in')); } } diff --git a/tests/unit/HealthTest.php b/tests/unit/HealthTest.php index f834ac60..ab3e2aa1 100644 --- a/tests/unit/HealthTest.php +++ b/tests/unit/HealthTest.php @@ -1,39 +1,36 @@ assertTrue($test); + $this->assertTrue(defined('APPPATH')); } public function testBaseUrlHasBeenSet() { $validation = Services::validation(); - $env = false; + + $env = false; // Check the baseURL in .env if (is_file(HOMEPATH . '.env')) { - $env = (bool) preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')); + $env = preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')) !== false; } if ($env) { // BaseURL in .env is a valid URL? // phpunit.xml.dist sets app.baseURL in $_SERVER // So if you set app.baseURL in .env, it takes precedence - $config = new Config\App(); + $config = new App(); $this->assertTrue( $validation->check($config->baseURL, 'valid_url'), 'baseURL "' . $config->baseURL . '" in .env is not valid URL' @@ -42,7 +39,7 @@ public function testBaseUrlHasBeenSet() // Get the baseURL in app/Config/App.php // You can't use Config\App, because phpunit.xml.dist sets app.baseURL - $reader = new \Tests\Support\Libraries\ConfigReader(); + $reader = new ConfigReader(); // BaseURL in app/Config/App.php is a valid URL? $this->assertTrue(