diff --git a/app/Config/App.php b/app/Config/App.php index 2127162..ffe0c6c 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -237,12 +237,14 @@ | recommended CSRF protection be enabled. | | CSRFTokenName = The token name + | CSRFHeaderName = The header name | CSRFCookieName = The cookie name | CSRFExpire = The number in seconds the token should expire. | CSRFRegenerate = Regenerate token on every submission | CSRFRedirect = Redirect to previous page with error on failure */ public $CSRFTokenName = 'csrf_test_name'; + public $CSRFHeaderName = 'X-CSRF-TOKEN'; public $CSRFCookieName = 'csrf_cookie_name'; public $CSRFExpire = 7200; public $CSRFRegenerate = true; diff --git a/license.txt b/license.txt index 6808958..6dea8d0 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2014-2019 British Columbia Institute of Technology +Copyright (c) 2019 CodeIgniter Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/system/API/ResponseTrait.php b/system/API/ResponseTrait.php index f887b11..e98ef0f 100644 --- a/system/API/ResponseTrait.php +++ b/system/API/ResponseTrait.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 598ae7b..dbd1c5d 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 0bacd15..7d3818b 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -292,7 +293,7 @@ { $namespaces[] = [ 'prefix' => $prefix, - 'path' => rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, + 'path' => rtrim($path, '\\/') . DIRECTORY_SEPARATOR, ]; } } diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index 6013927..158413e 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -195,7 +196,7 @@ * * @param string $key * - * @return bool + * @return boolean */ public function __isset(string $key): bool { diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index eb13b2a..ea17ddc 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php index 2d81124..50704ed 100644 --- a/system/CLI/CommandRunner.php +++ b/system/CLI/CommandRunner.php @@ -9,6 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CLI/Console.php b/system/CLI/Console.php index 43457b9..1affaf8 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/CacheFactory.php b/system/Cache/CacheFactory.php index 1e33daf..dc85548 100644 --- a/system/Cache/CacheFactory.php +++ b/system/Cache/CacheFactory.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index 2206db1..fc8fb90 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/DummyHandler.php b/system/Cache/Handlers/DummyHandler.php index a123a80..a60ce01 100644 --- a/system/Cache/Handlers/DummyHandler.php +++ b/system/Cache/Handlers/DummyHandler.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php index a33f893..da05026 100644 --- a/system/Cache/Handlers/FileHandler.php +++ b/system/Cache/Handlers/FileHandler.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index 9a07cff..6076da6 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php index 0e1f79b..5749565 100644 --- a/system/Cache/Handlers/PredisHandler.php +++ b/system/Cache/Handlers/PredisHandler.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index 54cb02d..17c8b13 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/WincacheHandler.php b/system/Cache/Handlers/WincacheHandler.php index f1a29d2..a49626f 100644 --- a/system/Cache/Handlers/WincacheHandler.php +++ b/system/Cache/Handlers/WincacheHandler.php @@ -9,6 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index fb9a171..ae6fe77 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +39,6 @@ namespace CodeIgniter; use Closure; -use CodeIgniter\Filters\Exceptions\FilterException; use CodeIgniter\HTTP\DownloadResponse; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\Request; @@ -50,6 +50,7 @@ use CodeIgniter\Events\Events; use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\CLIRequest; +use CodeIgniter\Router\Exceptions\RedirectException; use CodeIgniter\Router\RouteCollectionInterface; use CodeIgniter\Exceptions\PageNotFoundException; use Exception; @@ -65,7 +66,7 @@ /** * The current version of CodeIgniter Framework */ - const CI_VERSION = '4.0.0-rc.2'; + const CI_VERSION = '4.0.0-rc.3'; /** * App startup time. @@ -209,7 +210,7 @@ * @param boolean $returnResponse * * @return boolean|\CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed - * @throws \CodeIgniter\Filters\Exceptions\FilterException + * @throws \CodeIgniter\Router\Exceptions\RedirectException * @throws \Exception */ public function run(RouteCollectionInterface $routes = null, bool $returnResponse = false) @@ -244,7 +245,7 @@ { return $this->handleRequest($routes, $cacheConfig, $returnResponse); } - catch (FilterException $e) + catch (RedirectException $e) { $logger = Services::logger(); $logger->info('REDIRECTED ROUTE at ' . $e->getMessage()); @@ -252,6 +253,8 @@ // If the route is a 'redirect' route, it throws // the exception with the $to as the message $this->response->redirect($e->getMessage(), 'auto', $e->getCode()); + $this->sendResponse(); + $this->callExit(EXIT_SUCCESS); } catch (PageNotFoundException $e) diff --git a/system/Commands/Database/CreateMigration.php b/system/Commands/Database/CreateMigration.php index a674a39..db188fc 100644 --- a/system/Commands/Database/CreateMigration.php +++ b/system/Commands/Database/CreateMigration.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/Migrate.php b/system/Commands/Database/Migrate.php index a122dcb..6dd05b5 100644 --- a/system/Commands/Database/Migrate.php +++ b/system/Commands/Database/Migrate.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/MigrateRefresh.php b/system/Commands/Database/MigrateRefresh.php index 4468f16..5ea788b 100644 --- a/system/Commands/Database/MigrateRefresh.php +++ b/system/Commands/Database/MigrateRefresh.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/MigrateRollback.php b/system/Commands/Database/MigrateRollback.php index 515db07..37a2162 100644 --- a/system/Commands/Database/MigrateRollback.php +++ b/system/Commands/Database/MigrateRollback.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -119,12 +120,12 @@ { $batch = $params['-b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1; CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow'); - + if (! $runner->regress($batch)) { CLI::write(lang('Migrations.generalFault'), 'red'); } - + $messages = $runner->getCliMessages(); foreach ($messages as $message) { diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php index f0bc498..7355533 100644 --- a/system/Commands/Database/MigrateStatus.php +++ b/system/Commands/Database/MigrateStatus.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -165,7 +166,6 @@ $date = ''; foreach ($history as $row) { - if ($runner->getObjectUid($row) !== $uid) { continue; diff --git a/system/Commands/Database/Seed.php b/system/Commands/Database/Seed.php index f19445f..32a57dd 100644 --- a/system/Commands/Database/Seed.php +++ b/system/Commands/Database/Seed.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Help.php b/system/Commands/Help.php index 0678a23..3672e6c 100644 --- a/system/Commands/Help.php +++ b/system/Commands/Help.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php index 75e0708..e413aec 100644 --- a/system/Commands/ListCommands.php +++ b/system/Commands/ListCommands.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Server/Serve.php b/system/Commands/Server/Serve.php index 8ca15ab..3abae11 100644 --- a/system/Commands/Server/Serve.php +++ b/system/Commands/Server/Serve.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Sessions/CreateMigration.php b/system/Commands/Sessions/CreateMigration.php index 052eb07..d030b67 100644 --- a/system/Commands/Sessions/CreateMigration.php +++ b/system/Commands/Sessions/CreateMigration.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php index 36e0c77..2079a34 100644 --- a/system/Commands/Utilities/Namespaces.php +++ b/system/Commands/Utilities/Namespaces.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index ba37395..d516073 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Common.php b/system/Common.php index 85f2a76..d4ecc34 100644 --- a/system/Common.php +++ b/system/Common.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -723,6 +724,25 @@ //-------------------------------------------------------------------- +if (! function_exists('csrf_header')) +{ + /** + * Returns the CSRF header name. + * Can be used in Views by adding it to the meta tag + * or used in javascript to define a header name when using APIs. + * + * @return string + */ + function csrf_header(): string + { + $config = config(App::class); + + return $config->CSRFHeaderName; + } +} + +//-------------------------------------------------------------------- + if (! function_exists('csrf_hash')) { /** @@ -759,6 +779,23 @@ //-------------------------------------------------------------------- +if (! function_exists('csrf_meta')) +{ + /** + * Generates a meta tag for use within javascript calls. + * + * @param string|null $id + * + * @return string + */ + function csrf_meta(string $id = null): string + { + return ''; + } +} + +//-------------------------------------------------------------------- + if (! function_exists('force_https')) { /** diff --git a/system/ComposerScripts.php b/system/ComposerScripts.php index a4395cb..6cf41f9 100644 --- a/system/ComposerScripts.php +++ b/system/ComposerScripts.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/AutoloadConfig.php b/system/Config/AutoloadConfig.php index e68aa6c..57dd92e 100644 --- a/system/Config/AutoloadConfig.php +++ b/system/Config/AutoloadConfig.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index 5a1c662..2d5bbf1 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -9,6 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -107,7 +108,7 @@ /** * Initialization an environment-specific configuration setting * - * @param mixed &$property + * @param mixed &$property * @param string $name * @param string $prefix * @param string $shortPrefix diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index b94ef94..67f6cb6 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Config.php b/system/Config/Config.php index ae60dd3..6098037 100644 --- a/system/Config/Config.php +++ b/system/Config/Config.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/DotEnv.php b/system/Config/DotEnv.php index 1b4b58c..1828456 100644 --- a/system/Config/DotEnv.php +++ b/system/Config/DotEnv.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/ForeignCharacters.php b/system/Config/ForeignCharacters.php index 39db140..220ae10 100644 --- a/system/Config/ForeignCharacters.php +++ b/system/Config/ForeignCharacters.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Routes.php b/system/Config/Routes.php index 3cc1b09..40cc49c 100644 --- a/system/Config/Routes.php +++ b/system/Config/Routes.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Services.php b/system/Config/Services.php index 109410d..7eeaecb 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -209,10 +210,10 @@ $email = new \CodeIgniter\Email\Email($config); $email->setLogger(static::logger(true)); return $email; - } - - /** - * The Encryption class provides two-way encryption. + } + + /** + * The Encryption class provides two-way encryption. * * @param mixed $config * @param boolean $getShared diff --git a/system/Config/View.php b/system/Config/View.php index fcbf333..9e314a4 100644 --- a/system/Config/View.php +++ b/system/Config/View.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Controller.php b/system/Controller.php index 25a9d45..390d0de 100644 --- a/system/Controller.php +++ b/system/Controller.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index e2ab08b..2fbfd96 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -2488,6 +2489,7 @@ // Batch this baby $affected_rows = 0; $savedSQL = []; + $savedQBWhere = $this->QBWhere; for ($i = 0, $total = count($this->QBSet); $i < $total; $i += $batchSize) { $sql = $this->_updateBatch($table, array_slice($this->QBSet, $i, $batchSize), $this->db->protectIdentifiers($index) @@ -2503,7 +2505,7 @@ $affected_rows += $this->db->affectedRows(); } - $this->QBWhere = []; + $this->QBWhere = $savedQBWhere; } $this->resetWrite(); @@ -2690,7 +2692,7 @@ { $table = $this->QBFrom[0]; - $sql = $this->delete($table, '', $reset, true); + $sql = $this->delete($table, null, $reset, true); return $this->compileFinalQuery($sql); } diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 6fd5a49..038119a 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -1869,7 +1870,7 @@ * * @param string $key * - * @return bool + * @return boolean */ public function __isset(string $key): bool { diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index cbcfff7..d39239f 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index a5c17f6..d316c07 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/BaseUtils.php b/system/Database/BaseUtils.php index a512d23..0723562 100644 --- a/system/Database/BaseUtils.php +++ b/system/Database/BaseUtils.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Config.php b/system/Database/Config.php index f275066..2c079df 100644 --- a/system/Database/Config.php +++ b/system/Database/Config.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 302af16..26c38bd 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Database.php b/system/Database/Database.php index ec9c272..f27d3db 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Exceptions/DatabaseException.php b/system/Database/Exceptions/DatabaseException.php index af25053..96738c0 100644 --- a/system/Database/Exceptions/DatabaseException.php +++ b/system/Database/Exceptions/DatabaseException.php @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Forge.php b/system/Database/Forge.php index 2907cd6..c235fa1 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -105,6 +106,20 @@ protected $createDatabaseStr = 'CREATE DATABASE %s'; /** + * CREATE DATABASE IF statement + * + * @var string + */ + protected $createDatabaseIfStr = null; + + /** + * CHECK DATABASE EXIST statement + * + * @var string + */ + protected $checkDatabaseExistStr = null; + + /** * DROP DATABASE statement * * @var string @@ -199,13 +214,23 @@ /** * Create database * - * @param string $db_name + * @param string $dbName + * @param boolean $ifNotExists Whether to add IF NOT EXISTS condition * * @return boolean * @throws \CodeIgniter\Database\Exceptions\DatabaseException */ - public function createDatabase(string $db_name): bool + public function createDatabase(string $dbName, bool $ifNotExists = false): bool { + if ($ifNotExists && $this->createDatabaseIfStr === null) + { + if ($this->databaseExists($dbName)) + { + return true; + } + $ifNotExists = false; + } + if ($this->createDatabaseStr === false) { if ($this->db->DBDebug) @@ -215,7 +240,7 @@ return false; } - elseif (! $this->db->query(sprintf($this->createDatabaseStr, $db_name, $this->db->charset, $this->db->DBCollat)) + elseif (! $this->db->query(sprintf($ifNotExists ? $this->createDatabaseIfStr : $this->createDatabaseStr, $dbName, $this->db->charset, $this->db->DBCollat)) ) { if ($this->db->DBDebug) @@ -228,7 +253,7 @@ if (! empty($this->db->dataCache['db_names'])) { - $this->db->dataCache['db_names'][] = $db_name; + $this->db->dataCache['db_names'][] = $dbName; } return true; @@ -237,14 +262,39 @@ //-------------------------------------------------------------------- /** - * Drop database + * Determine if a database exists * - * @param string $db_name + * @param string $dbName * * @return boolean * @throws \CodeIgniter\Database\Exceptions\DatabaseException */ - public function dropDatabase(string $db_name): bool + private function databaseExists(string $dbName): bool + { + if ($this->checkDatabaseExistStr === null) + { + if ($this->db->DBDebug) + { + throw new DatabaseException('This feature is not available for the database you are using.'); + } + + return false; + } + + return $this->db->query($this->checkDatabaseExistStr, $dbName)->getRow() !== null; + } + + //-------------------------------------------------------------------- + + /** + * Drop database + * + * @param string $dbName + * + * @return boolean + * @throws \CodeIgniter\Database\Exceptions\DatabaseException + */ + public function dropDatabase(string $dbName): bool { if ($this->dropDatabaseStr === false) { @@ -255,7 +305,7 @@ return false; } - elseif (! $this->db->query(sprintf($this->dropDatabaseStr, $db_name))) + elseif (! $this->db->query(sprintf($this->dropDatabaseStr, $dbName))) { if ($this->db->DBDebug) { @@ -267,7 +317,7 @@ if (! empty($this->db->dataCache['db_names'])) { - $key = array_search(strtolower($db_name), array_map('strtolower', $this->db->dataCache['db_names']), true); + $key = array_search(strtolower($dbName), array_map('strtolower', $this->db->dataCache['db_names']), true); if ($key !== false) { unset($this->db->dataCache['db_names'][$key]); diff --git a/system/Database/Migration.php b/system/Database/Migration.php index bfa31a9..7d53c23 100644 --- a/system/Database/Migration.php +++ b/system/Database/Migration.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -74,7 +75,7 @@ */ public function __construct(Forge $forge = null) { - $this->forge = ! is_null($forge) ? $forge : \Config\Database::forge($this->DBGroup); + $this->forge = ! is_null($forge) ? $forge : \Config\Database::forge($this->DBGroup ?? config('Database')->defaultGroup); $this->db = $this->forge->getConnection(); } @@ -86,7 +87,7 @@ * * @return string */ - public function getDBGroup(): string + public function getDBGroup(): ?string { return $this->DBGroup; } diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 25fe423..4407363 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -128,6 +129,20 @@ */ protected $path; + /** + * The database Group filter. + * + * @var string + */ + protected $groupFilter; + + /** + * Used to skip current migration. + * + * @var boolean + */ + protected $groupSkip = false; + //-------------------------------------------------------------------- /** @@ -180,6 +195,7 @@ // Set database group if not null if (! is_null($group)) { + $this->groupFilter = $group; $this->setGroup($group); } @@ -206,6 +222,12 @@ { if ($this->migrate('up', $migration)) { + if ($this->groupSkip === true) + { + $this->groupSkip = false; + continue; + } + $this->addHistory($migration, $batch); } // If a migration failed then try to back out what was done @@ -370,6 +392,7 @@ // Set database group if not null if (! is_null($group)) { + $this->groupFilter = $group; $this->setGroup($group); } @@ -406,11 +429,13 @@ // Start a new batch $batch = $this->getLastBatch() + 1; - if ($this->migrate('up', $migration)) + if ($this->migrate('up', $migration) && $this->groupSkip === false) { $this->addHistory($migration, $batch); return true; } + + $this->groupSkip = false; } // down @@ -991,8 +1016,19 @@ throw new \RuntimeException($message); } - // Forcing migration to selected database group - $instance = new $class(\Config\Database::forge($this->group)); + // Initialize migration + $instance = new $class(); + // Determine DBGroup to use + $group = $instance->getDBGroup() ?? config('Database')->defaultGroup; + + // Skip migration if group filtering was set + if ($direction === 'up' && ! is_null($this->groupFilter) && $this->groupFilter !== $group) + { + $this->groupSkip = true; + return true; + } + + $this->setGroup($group); if (! is_callable([$instance, $direction])) { diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php index 6bfe554..908f571 100644 --- a/system/Database/MySQLi/Builder.php +++ b/system/Database/MySQLi/Builder.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -53,4 +54,24 @@ */ protected $escapeChar = '`'; + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * Note: This is only used (and overridden) by MySQL. + * + * @return string + */ + protected function _fromTables(): string + { + if (! empty($this->QBJoin) && count($this->QBFrom) > 1) + { + return '(' . implode(', ', $this->QBFrom) . ')'; + } + + return implode(', ', $this->QBFrom); + } + } diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 059c860..70c3f9c 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -395,7 +396,7 @@ * additional "ESCAPE x" parameter for specifying the escape character * in "LIKE" strings, and this handles those directly with a backslash. * - * @param string|string[] $str Input string + * @param string|string[] $str Input string * @return string|string[] */ public function escapeLikeStringDirect($str) @@ -428,7 +429,7 @@ } //-------------------------------------------------------------------- - + /** * Generates the SQL for listing tables in a platform-dependent manner. * Uses escapeLikeStringDirect(). diff --git a/system/Database/MySQLi/Forge.php b/system/Database/MySQLi/Forge.php index 52168af..c17f1ac 100644 --- a/system/Database/MySQLi/Forge.php +++ b/system/Database/MySQLi/Forge.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -52,6 +53,13 @@ protected $createDatabaseStr = 'CREATE DATABASE %s CHARACTER SET %s COLLATE %s'; /** + * CREATE DATABASE IF statement + * + * @var string + */ + protected $createDatabaseIfStr = 'CREATE DATABASE IF NOT EXISTS %s CHARACTER SET %s COLLATE %s'; + + /** * DROP CONSTRAINT statement * * @var string diff --git a/system/Database/MySQLi/PreparedQuery.php b/system/Database/MySQLi/PreparedQuery.php index a510a37..ef02018 100644 --- a/system/Database/MySQLi/PreparedQuery.php +++ b/system/Database/MySQLi/PreparedQuery.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MySQLi/Result.php b/system/Database/MySQLi/Result.php index 630a4f7..65cb23f 100644 --- a/system/Database/MySQLi/Result.php +++ b/system/Database/MySQLi/Result.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MySQLi/Utils.php b/system/Database/MySQLi/Utils.php index 5ebe7fb..799a03d 100644 --- a/system/Database/MySQLi/Utils.php +++ b/system/Database/MySQLi/Utils.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index e86f37c..a7424b0 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index be9556a..4dac1ec 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Forge.php b/system/Database/Postgre/Forge.php index 1dcbaf8..d0ad4f1 100644 --- a/system/Database/Postgre/Forge.php +++ b/system/Database/Postgre/Forge.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -45,6 +46,13 @@ { /** + * CHECK DATABASE EXIST statement + * + * @var string + */ + protected $checkDatabaseExistStr = 'SELECT 1 FROM pg_database WHERE datname = ?'; + + /** * DROP CONSTRAINT statement * * @var string @@ -74,7 +82,7 @@ * @var string */ protected $_null = 'NULL'; - + //-------------------------------------------------------------------- /** diff --git a/system/Database/Postgre/PreparedQuery.php b/system/Database/Postgre/PreparedQuery.php index 9cf88bd..d1598cc 100644 --- a/system/Database/Postgre/PreparedQuery.php +++ b/system/Database/Postgre/PreparedQuery.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Result.php b/system/Database/Postgre/Result.php index 106a7e1..a33f9f0 100644 --- a/system/Database/Postgre/Result.php +++ b/system/Database/Postgre/Result.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Utils.php b/system/Database/Postgre/Utils.php index aa95536..85965a0 100644 --- a/system/Database/Postgre/Utils.php +++ b/system/Database/Postgre/Utils.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/PreparedQueryInterface.php b/system/Database/PreparedQueryInterface.php index d29e250..1ddbad0 100644 --- a/system/Database/PreparedQueryInterface.php +++ b/system/Database/PreparedQueryInterface.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Query.php b/system/Database/Query.php index 06d1359..e1af64f 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/QueryInterface.php b/system/Database/QueryInterface.php index f7381b9..423ac9f 100644 --- a/system/Database/QueryInterface.php +++ b/system/Database/QueryInterface.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php index 6ebfe2c..d8413b2 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Builder.php b/system/Database/SQLite3/Builder.php index ba09b58..911b9fe 100644 --- a/system/Database/SQLite3/Builder.php +++ b/system/Database/SQLite3/Builder.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index f03b6bb..0ce1dac 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Forge.php b/system/Database/SQLite3/Forge.php index e19d4b6..877c78e 100644 --- a/system/Database/SQLite3/Forge.php +++ b/system/Database/SQLite3/Forge.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -84,11 +85,12 @@ /** * Create database * - * @param string $db_name + * @param string $dbName + * @param boolean $ifNotExists Whether to add IF NOT EXISTS condition * * @return boolean */ - public function createDatabase(string $db_name): bool + public function createDatabase(string $dbName, bool $ifNotExists = false): bool { // In SQLite, a database is created when you connect to the database. // We'll return TRUE so that an error isn't generated. @@ -100,15 +102,15 @@ /** * Drop database * - * @param string $db_name + * @param string $dbName * * @return boolean * @throws \CodeIgniter\Database\Exceptions\DatabaseException */ - public function dropDatabase(string $db_name): bool + public function dropDatabase(string $dbName): bool { // In SQLite, a database is dropped when we delete a file - if (! is_file($db_name)) + if (! is_file($dbName)) { if ($this->db->DBDebug) { @@ -120,7 +122,7 @@ // We need to close the pseudo-connection first $this->db->close(); - if (! @unlink($db_name)) + if (! @unlink($dbName)) { if ($this->db->DBDebug) { @@ -132,7 +134,7 @@ if (! empty($this->db->dataCache['db_names'])) { - $key = array_search(strtolower($db_name), array_map('strtolower', $this->db->dataCache['db_names']), true); + $key = array_search(strtolower($dbName), array_map('strtolower', $this->db->dataCache['db_names']), true); if ($key !== false) { unset($this->db->dataCache['db_names'][$key]); diff --git a/system/Database/SQLite3/PreparedQuery.php b/system/Database/SQLite3/PreparedQuery.php index 8ffb502..8f73385 100644 --- a/system/Database/SQLite3/PreparedQuery.php +++ b/system/Database/SQLite3/PreparedQuery.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php index 3d56715..3d8c53a 100644 --- a/system/Database/SQLite3/Result.php +++ b/system/Database/SQLite3/Result.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Table.php b/system/Database/SQLite3/Table.php index 14973d5..a15f9a0 100644 --- a/system/Database/SQLite3/Table.php +++ b/system/Database/SQLite3/Table.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Utils.php b/system/Database/SQLite3/Utils.php index 5c4263a..f7cb337 100644 --- a/system/Database/SQLite3/Utils.php +++ b/system/Database/SQLite3/Utils.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Seeder.php b/system/Database/Seeder.php index 18c8304..023cb4e 100644 --- a/system/Database/Seeder.php +++ b/system/Database/Seeder.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 6e6b33a..a3ed7bf 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -461,7 +462,7 @@ $source = array_splice($source, $start, $lines, true); // Used to format the line number in the source - $format = '% ' . strlen(sprintf('%sd', $start + $lines)); + $format = '% ' . strlen(sprintf('%s', $start + $lines)) . 'd'; $out = ''; // Because the highlighting may have an uneven number diff --git a/system/Debug/Iterator.php b/system/Debug/Iterator.php index abad5f4..8f97807 100644 --- a/system/Debug/Iterator.php +++ b/system/Debug/Iterator.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Timer.php b/system/Debug/Timer.php index ab5fc2d..1d6438e 100644 --- a/system/Debug/Timer.php +++ b/system/Debug/Timer.php @@ -8,6 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 6994684..4e218bc 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -7,6 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology + * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/) + * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -57,6 +58,7 @@ */ class Toolbar { + /** * Toolbar configuration settings. * @@ -87,7 +89,7 @@ if (! class_exists($collector)) { log_message('critical', 'Toolbar collector does not exists(' . $collector . ').' . - 'please check $collectors in the Config\Toolbar.php file.'); + 'please check $collectors in the Config\Toolbar.php file.'); continue; } @@ -117,7 +119,7 @@ $data['totalTime'] = $totalTime * 1000; $data['totalMemory'] = number_format((memory_get_peak_usage()) / 1024 / 1024, 3); $data['segmentDuration'] = $this->roundTo($data['totalTime'] / 7, 5); - $data['segmentCount'] = (int)ceil($data['totalTime'] / $data['segmentDuration']); + $data['segmentCount'] = (int) ceil($data['totalTime'] / $data['segmentDuration']); $data['CI_VERSION'] = \CodeIgniter\CodeIgniter::CI_VERSION; $data['collectors'] = []; @@ -200,14 +202,13 @@ if ($response->CSP !== null) { - $response->CSP->addImageSrc( 'data:' ); + $response->CSP->addImageSrc('data:'); } return json_encode($data); } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- /** @@ -221,7 +222,7 @@ * * @return string */ - protected function renderTimeline(array $collectors, $startTime, int $segmentCount, int $segmentDuration, array &$styles): string + protected function renderTimeline(array $collectors, float $startTime, int $segmentCount, int $segmentDuration, array &$styles): string { $displayTime = $segmentCount * $segmentDuration; $rows = $this->collectTimelineData($collectors); @@ -236,15 +237,15 @@ $output .= "