mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge remote-tracking branch 'upstream/develop' into 4.6
# Conflicts: # composer.json # utils/phpstan-baseline/missingType.iterableValue.neon
This commit is contained in:
commit
c3bfac5261
@ -28,7 +28,7 @@
|
|||||||
"phpunit/phpcov": "^9.0.2 || ^10.0",
|
"phpunit/phpcov": "^9.0.2 || ^10.0",
|
||||||
"phpunit/phpunit": "^10.5.16 || ^11.2",
|
"phpunit/phpunit": "^10.5.16 || ^11.2",
|
||||||
"predis/predis": "^1.1 || ^2.3",
|
"predis/predis": "^1.1 || ^2.3",
|
||||||
"rector/rector": "2.0.4",
|
"rector/rector": "2.0.5",
|
||||||
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
|
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
|
@ -289,7 +289,7 @@ class CLI
|
|||||||
|
|
||||||
CLI::isZeroOptions($options);
|
CLI::isZeroOptions($options);
|
||||||
|
|
||||||
if ($line = array_shift($text)) {
|
if (($line = array_shift($text)) !== null) {
|
||||||
CLI::write($line);
|
CLI::write($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ class CLI
|
|||||||
// return the prompt again if $input contain(s) non-numeric character, except a comma.
|
// return the prompt again if $input contain(s) non-numeric character, except a comma.
|
||||||
// And if max from $options less than max from input,
|
// And if max from $options less than max from input,
|
||||||
// it means user tried to access null value in $options
|
// it means user tried to access null value in $options
|
||||||
if ($pattern === 0 || $maxOptions < $maxInput) {
|
if ($pattern < 1 || $maxOptions < $maxInput) {
|
||||||
static::error('Please select correctly.');
|
static::error('Please select correctly.');
|
||||||
CLI::newLine();
|
CLI::newLine();
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ class BaseBuilder
|
|||||||
} else {
|
} else {
|
||||||
// Split multiple conditions
|
// Split multiple conditions
|
||||||
// @TODO This does not parse `BETWEEN a AND b` correctly.
|
// @TODO This does not parse `BETWEEN a AND b` correctly.
|
||||||
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) {
|
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
$joints = $joints[0];
|
$joints = $joints[0];
|
||||||
array_unshift($joints, ['', 0]);
|
array_unshift($joints, ['', 0]);
|
||||||
@ -2203,7 +2203,7 @@ class BaseBuilder
|
|||||||
*
|
*
|
||||||
* @param array|object|null $set a dataset
|
* @param array|object|null $set a dataset
|
||||||
*
|
*
|
||||||
* @return false|int|list<string> Number of rows inserted or FALSE on failure, SQL array when testMode
|
* @return false|int|list<string> Number of rows inserted or FALSE on no data to perform an insert operation, SQL array when testMode
|
||||||
*/
|
*/
|
||||||
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
|
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
|
||||||
{
|
{
|
||||||
@ -3477,7 +3477,7 @@ class BaseBuilder
|
|||||||
'/' . implode('|', $this->pregOperators) . '/i',
|
'/' . implode('|', $this->pregOperators) . '/i',
|
||||||
$str,
|
$str,
|
||||||
$match
|
$match
|
||||||
) ? ($list ? $match[0] : $match[0][0]) : false;
|
) >= 1 ? ($list ? $match[0] : $match[0][0]) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3508,7 +3508,7 @@ class BaseBuilder
|
|||||||
'/' . implode('|', $pregOperators) . '/i',
|
'/' . implode('|', $pregOperators) . '/i',
|
||||||
$whereKey,
|
$whereKey,
|
||||||
$match
|
$match
|
||||||
) ? $match[0] : false;
|
) >= 1 ? $match[0] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,6 +228,10 @@ class Connection extends BaseConnection
|
|||||||
*/
|
*/
|
||||||
public function affectedRows(): int
|
public function affectedRows(): int
|
||||||
{
|
{
|
||||||
|
if ($this->resultID === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return pg_affected_rows($this->resultID);
|
return pg_affected_rows($this->resultID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ class Query implements QueryInterface, Stringable
|
|||||||
*/
|
*/
|
||||||
protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string
|
protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string
|
||||||
{
|
{
|
||||||
if ($c = preg_match_all("/'[^']*'/", $sql, $matches)) {
|
if ($c = preg_match_all("/'[^']*'/", $sql, $matches) >= 1) {
|
||||||
$c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE);
|
$c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE);
|
||||||
|
|
||||||
// Bind values' count must match the count of markers in the query
|
// Bind values' count must match the count of markers in the query
|
||||||
|
@ -122,7 +122,7 @@ class Builder extends BaseBuilder
|
|||||||
$cond = ' ON ' . $cond;
|
$cond = ' ON ' . $cond;
|
||||||
} else {
|
} else {
|
||||||
// Split multiple conditions
|
// Split multiple conditions
|
||||||
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) {
|
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
$joints = $joints[0];
|
$joints = $joints[0];
|
||||||
array_unshift($joints, ['', 0]);
|
array_unshift($joints, ['', 0]);
|
||||||
|
@ -453,6 +453,10 @@ class Connection extends BaseConnection
|
|||||||
*/
|
*/
|
||||||
public function affectedRows(): int
|
public function affectedRows(): int
|
||||||
{
|
{
|
||||||
|
if ($this->resultID === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return sqlsrv_rows_affected($this->resultID);
|
return sqlsrv_rows_affected($this->resultID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,7 +1031,7 @@ class Email
|
|||||||
|
|
||||||
$unwrap = [];
|
$unwrap = [];
|
||||||
|
|
||||||
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) {
|
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) {
|
||||||
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
|
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
|
||||||
$unwrap[] = $matches[1][$i];
|
$unwrap[] = $matches[1][$i];
|
||||||
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
|
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
|
||||||
|
@ -132,7 +132,7 @@ if (! function_exists('entities_to_ascii')) {
|
|||||||
*/
|
*/
|
||||||
function entities_to_ascii(string $str, bool $all = true): string
|
function entities_to_ascii(string $str, bool $all = true): string
|
||||||
{
|
{
|
||||||
if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) {
|
if (preg_match_all('/\&#(\d+)\;/', $str, $matches) >= 1) {
|
||||||
for ($i = 0, $s = count($matches[0]); $i < $s; $i++) {
|
for ($i = 0, $s = count($matches[0]); $i < $s; $i++) {
|
||||||
$digits = (int) $matches[1][$i];
|
$digits = (int) $matches[1][$i];
|
||||||
$out = '';
|
$out = '';
|
||||||
@ -196,7 +196,7 @@ if (! function_exists('word_censor')) {
|
|||||||
"\\1{$replacement}\\3",
|
"\\1{$replacement}\\3",
|
||||||
$str
|
$str
|
||||||
);
|
);
|
||||||
} elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
|
} elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) >= 1) {
|
||||||
$matches = $matches[1];
|
$matches = $matches[1];
|
||||||
|
|
||||||
for ($i = count($matches) - 1; $i >= 0; $i--) {
|
for ($i = count($matches) - 1; $i >= 0; $i--) {
|
||||||
@ -352,7 +352,7 @@ if (! function_exists('word_wrap')) {
|
|||||||
// strip the entire chunk and replace it with a marker.
|
// strip the entire chunk and replace it with a marker.
|
||||||
$unwrap = [];
|
$unwrap = [];
|
||||||
|
|
||||||
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) {
|
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) {
|
||||||
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
|
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
|
||||||
$unwrap[] = $matches[1][$i];
|
$unwrap[] = $matches[1][$i];
|
||||||
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
|
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
|
||||||
|
@ -360,7 +360,7 @@ if (! function_exists('auto_link')) {
|
|||||||
$str,
|
$str,
|
||||||
$matches,
|
$matches,
|
||||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||||
)
|
) >= 1
|
||||||
) {
|
) {
|
||||||
// Set our target HTML if using popup links.
|
// Set our target HTML if using popup links.
|
||||||
$target = ($popup) ? ' target="_blank"' : '';
|
$target = ($popup) ? ' target="_blank"' : '';
|
||||||
@ -387,7 +387,7 @@ if (! function_exists('auto_link')) {
|
|||||||
$str,
|
$str,
|
||||||
$matches,
|
$matches,
|
||||||
PREG_OFFSET_CAPTURE
|
PREG_OFFSET_CAPTURE
|
||||||
)
|
) >= 1
|
||||||
) {
|
) {
|
||||||
foreach (array_reverse($matches[0]) as $match) {
|
foreach (array_reverse($matches[0]) as $match) {
|
||||||
if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== false) {
|
if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== false) {
|
||||||
|
@ -396,23 +396,6 @@ abstract class BaseHandler implements ImageHandlerInterface
|
|||||||
*/
|
*/
|
||||||
abstract protected function _flip(string $direction);
|
abstract protected function _flip(string $direction);
|
||||||
|
|
||||||
/**
|
|
||||||
* Overlays a string of text over the image.
|
|
||||||
*
|
|
||||||
* Valid options:
|
|
||||||
*
|
|
||||||
* - color Text Color (hex number)
|
|
||||||
* - shadowColor Color of the shadow (hex number)
|
|
||||||
* - hAlign Horizontal alignment: left, center, right
|
|
||||||
* - vAlign Vertical alignment: top, middle, bottom
|
|
||||||
* - hOffset
|
|
||||||
* - vOffset
|
|
||||||
* - fontPath
|
|
||||||
* - fontSize
|
|
||||||
* - shadowOffset
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function text(string $text, array $options = [])
|
public function text(string $text, array $options = [])
|
||||||
{
|
{
|
||||||
$options = array_merge($this->textDefaults, $options);
|
$options = array_merge($this->textDefaults, $options);
|
||||||
@ -427,6 +410,21 @@ abstract class BaseHandler implements ImageHandlerInterface
|
|||||||
/**
|
/**
|
||||||
* Handler-specific method for overlaying text on an image.
|
* Handler-specific method for overlaying text on an image.
|
||||||
*
|
*
|
||||||
|
* @param array{
|
||||||
|
* color?: string,
|
||||||
|
* shadowColor?: string,
|
||||||
|
* hAlign?: string,
|
||||||
|
* vAlign?: string,
|
||||||
|
* hOffset?: int,
|
||||||
|
* vOffset?: int,
|
||||||
|
* fontPath?: string,
|
||||||
|
* fontSize?: int,
|
||||||
|
* shadowOffset?: int,
|
||||||
|
* opacity?: float,
|
||||||
|
* padding?: int,
|
||||||
|
* withShadow?: bool|string
|
||||||
|
* } $options
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract protected function _text(string $text, array $options = []);
|
abstract protected function _text(string $text, array $options = []);
|
||||||
|
@ -329,8 +329,6 @@ class ImageMagickHandler extends BaseHandler
|
|||||||
/**
|
/**
|
||||||
* Handler-specific method for overlaying text on an image.
|
* Handler-specific method for overlaying text on an image.
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function _text(string $text, array $options = [])
|
protected function _text(string $text, array $options = [])
|
||||||
|
@ -117,11 +117,21 @@ interface ImageHandlerInterface
|
|||||||
* - shadowColor Color of the shadow (hex number)
|
* - shadowColor Color of the shadow (hex number)
|
||||||
* - hAlign Horizontal alignment: left, center, right
|
* - hAlign Horizontal alignment: left, center, right
|
||||||
* - vAlign Vertical alignment: top, middle, bottom
|
* - vAlign Vertical alignment: top, middle, bottom
|
||||||
* - hOffset
|
*
|
||||||
* - vOffset
|
* @param array{
|
||||||
* - fontPath
|
* color?: string,
|
||||||
* - fontSize
|
* shadowColor?: string,
|
||||||
* - shadowOffset
|
* hAlign?: string,
|
||||||
|
* vAlign?: string,
|
||||||
|
* hOffset?: int,
|
||||||
|
* vOffset?: int,
|
||||||
|
* fontPath?: string,
|
||||||
|
* fontSize?: int,
|
||||||
|
* shadowOffset?: int,
|
||||||
|
* opacity?: float,
|
||||||
|
* padding?: int,
|
||||||
|
* withShadow?: bool|string
|
||||||
|
* } $options
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +98,7 @@ class MemcachedHandler extends BaseHandler
|
|||||||
$this->savePath,
|
$this->savePath,
|
||||||
$matches,
|
$matches,
|
||||||
PREG_SET_ORDER
|
PREG_SET_ORDER
|
||||||
) === 0
|
) < 1
|
||||||
) {
|
) {
|
||||||
$this->memcached = null;
|
$this->memcached = null;
|
||||||
$this->logger->error('Session: Invalid Memcached save path format: ' . $this->savePath);
|
$this->logger->error('Session: Invalid Memcached save path format: ' . $this->savePath);
|
||||||
|
@ -31,7 +31,7 @@ class MockCache extends BaseHandler implements CacheInterface
|
|||||||
/**
|
/**
|
||||||
* Expiration times.
|
* Expiration times.
|
||||||
*
|
*
|
||||||
* @var ?list<int>
|
* @var array<string, int|null>
|
||||||
*/
|
*/
|
||||||
protected $expirations = [];
|
protected $expirations = [];
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class Typography
|
|||||||
|
|
||||||
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
|
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
|
||||||
$htmlComments = [];
|
$htmlComments = [];
|
||||||
if (str_contains($str, '<!--') && preg_match_all('#(<!\-\-.*?\-\->)#s', $str, $matches)) {
|
if (str_contains($str, '<!--') && preg_match_all('#(<!\-\-.*?\-\->)#s', $str, $matches) >= 1) {
|
||||||
for ($i = 0, $total = count($matches[0]); $i < $total; $i++) {
|
for ($i = 0, $total = count($matches[0]); $i < $total; $i++) {
|
||||||
$htmlComments[] = $matches[0][$i];
|
$htmlComments[] = $matches[0][$i];
|
||||||
$str = str_replace($matches[0][$i], '{@HC' . $i . '}', $str);
|
$str = str_replace($matches[0][$i], '{@HC' . $i . '}', $str);
|
||||||
|
@ -419,7 +419,7 @@ class Parser extends View
|
|||||||
* $matches[][0] is the raw match
|
* $matches[][0] is the raw match
|
||||||
* $matches[][1] is the contents
|
* $matches[][1] is the contents
|
||||||
*/
|
*/
|
||||||
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) {
|
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER) >= 1) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
// Create a hash of the contents to insert in its place.
|
// Create a hash of the contents to insert in its place.
|
||||||
$hash = md5($match[1]);
|
$hash = md5($match[1]);
|
||||||
@ -691,7 +691,7 @@ class Parser extends View
|
|||||||
* $matches[1] = all parameters string in opening tag
|
* $matches[1] = all parameters string in opening tag
|
||||||
* $matches[2] = content between the tags to send to the plugin.
|
* $matches[2] = content between the tags to send to the plugin.
|
||||||
*/
|
*/
|
||||||
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER) === 0) {
|
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER) < 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ final class CommonHelperTest extends CIUnitTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertSame($this->dummyHelpers[0], foo_bar_baz());
|
$this->assertSame($this->dummyHelpers[0], foo_bar_baz()); // @phpstan-ignore-line function.notFound
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNamespacedHelperNotFound(): void
|
public function testNamespacedHelperNotFound(): void
|
||||||
|
@ -19,6 +19,7 @@ use CodeIgniter\Database\RawSql;
|
|||||||
use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder;
|
use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder;
|
||||||
use CodeIgniter\Test\CIUnitTestCase;
|
use CodeIgniter\Test\CIUnitTestCase;
|
||||||
use CodeIgniter\Test\Mock\MockConnection;
|
use CodeIgniter\Test\Mock\MockConnection;
|
||||||
|
use Generator;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\Attributes\Group;
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ final class SelectTest extends CIUnitTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<list<RawSql|string>|string>
|
* @return Generator<list<RawSql|string>|string>
|
||||||
*/
|
*/
|
||||||
public static function provideSelectAcceptsArrayWithRawSql(): iterable
|
public static function provideSelectAcceptsArrayWithRawSql(): iterable
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CodeIgniter\Database\Live;
|
namespace CodeIgniter\Database\Live;
|
||||||
|
|
||||||
|
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||||
use CodeIgniter\Database\Forge;
|
use CodeIgniter\Database\Forge;
|
||||||
use CodeIgniter\Database\RawSql;
|
use CodeIgniter\Database\RawSql;
|
||||||
use CodeIgniter\Test\CIUnitTestCase;
|
use CodeIgniter\Test\CIUnitTestCase;
|
||||||
@ -79,13 +80,41 @@ final class InsertTest extends CIUnitTestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->db->table($table)->insertBatch($data);
|
$count = $this->db->table($table)->insertBatch($data);
|
||||||
|
|
||||||
|
$this->assertSame(2, $count);
|
||||||
|
|
||||||
$expected = $data;
|
$expected = $data;
|
||||||
$this->seeInDatabase($table, $expected[0]);
|
$this->seeInDatabase($table, $expected[0]);
|
||||||
$this->seeInDatabase($table, $expected[1]);
|
$this->seeInDatabase($table, $expected[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInsertBatchFailed(): void
|
||||||
|
{
|
||||||
|
$this->expectException(DatabaseException::class);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'name' => 'Grocery Sales',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$db = $this->db;
|
||||||
|
|
||||||
|
if ($this->db->DBDriver === 'MySQLi') {
|
||||||
|
// strict mode is required for MySQLi to throw an exception here
|
||||||
|
$config = config('Database');
|
||||||
|
$config->tests['strictOn'] = true;
|
||||||
|
|
||||||
|
$db = Database::connect($config->tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->table('job')->insertBatch($data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testReplaceWithNoMatchingData(): void
|
public function testReplaceWithNoMatchingData(): void
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -239,4 +239,40 @@ final class TransactionTest extends CIUnitTestCase
|
|||||||
|
|
||||||
$this->enableDBDebug();
|
$this->enableDBDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://github.com/codeigniter4/CodeIgniter4/issues/9362
|
||||||
|
*/
|
||||||
|
public function testTransInsertBatchFailed(): void
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'name' => 'Grocery Sales',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$db = $this->db;
|
||||||
|
|
||||||
|
if ($this->db->DBDriver === 'MySQLi') {
|
||||||
|
// strict mode is required for MySQLi to throw an exception here
|
||||||
|
$config = config('Database');
|
||||||
|
$config->tests['strictOn'] = true;
|
||||||
|
|
||||||
|
$db = Database::connect($config->tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->transStrict(false)->transBegin();
|
||||||
|
$db->table('job')->insertBatch($data);
|
||||||
|
|
||||||
|
$this->assertFalse($db->transStatus());
|
||||||
|
|
||||||
|
$db->transComplete();
|
||||||
|
|
||||||
|
$db->transStrict();
|
||||||
|
|
||||||
|
$this->dontSeeInDatabase('job', ['name' => 'Grocery Sales']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ Deprecations
|
|||||||
Bugs Fixed
|
Bugs Fixed
|
||||||
**********
|
**********
|
||||||
|
|
||||||
|
- **Database:** Fixed a bug where ``Builder::affectedRows()`` threw an error when the previous query call failed in ``Postgre`` and ``SQLSRV`` drivers.
|
||||||
|
|
||||||
See the repo's
|
See the repo's
|
||||||
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
|
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
|
||||||
for a complete list of bugs fixed.
|
for a complete list of bugs fixed.
|
||||||
|
@ -1870,7 +1870,7 @@ Class Reference
|
|||||||
:param array $set: Data to insert
|
:param array $set: Data to insert
|
||||||
:param bool $escape: Whether to escape values
|
:param bool $escape: Whether to escape values
|
||||||
:param int $batch_size: Count of rows to insert at once
|
:param int $batch_size: Count of rows to insert at once
|
||||||
:returns: Number of rows inserted or ``false`` on failure
|
:returns: Number of rows inserted or ``false`` on no data to perform an insert operation
|
||||||
:rtype: int|false
|
:rtype: int|false
|
||||||
|
|
||||||
Compiles and executes batch ``INSERT`` statements.
|
Compiles and executes batch ``INSERT`` statements.
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
# total 1 error
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: '#^Function foo_bar_baz not found\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../tests/system/CommonHelperTest.php
|
|
@ -1,8 +0,0 @@
|
|||||||
# total 1 error
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: '#^Yield can be used only with these return types\: Generator, Iterator, Traversable, iterable\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../tests/system/Database/Builder/SelectTest.php
|
|
@ -1,8 +0,0 @@
|
|||||||
# total 1 error
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: '#^Comparison operation "\>\=" between \(array\|float\|int\) and 0 results in an error\.$#'
|
|
||||||
count: 2
|
|
||||||
path: ../../system/Images/Handlers/ImageMagickHandler.php
|
|
@ -1,8 +0,0 @@
|
|||||||
# total 1 error
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../system/CLI/CLI.php
|
|
@ -18,11 +18,7 @@ includes:
|
|||||||
- expr.resultUnused.neon
|
- expr.resultUnused.neon
|
||||||
- function.alreadyNarrowedType.neon
|
- function.alreadyNarrowedType.neon
|
||||||
- function.inner.neon
|
- function.inner.neon
|
||||||
- function.notFound.neon
|
|
||||||
- generator.returnType.neon
|
|
||||||
- generator.valueType.neon
|
- generator.valueType.neon
|
||||||
- greaterOrEqual.invalid.neon
|
|
||||||
- if.condNotBoolean.neon
|
|
||||||
- isset.offset.neon
|
- isset.offset.neon
|
||||||
- isset.property.neon
|
- isset.property.neon
|
||||||
- method.alreadyNarrowedType.neon
|
- method.alreadyNarrowedType.neon
|
||||||
@ -55,6 +51,5 @@ includes:
|
|||||||
- return.unusedType.neon
|
- return.unusedType.neon
|
||||||
- staticMethod.notFound.neon
|
- staticMethod.notFound.neon
|
||||||
- ternary.shortNotAllowed.neon
|
- ternary.shortNotAllowed.neon
|
||||||
- unset.offset.neon
|
|
||||||
- varTag.type.neon
|
- varTag.type.neon
|
||||||
- variable.undefined.neon
|
- variable.undefined.neon
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# total 1672 errors
|
# total 1667 errors
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
@ -4632,11 +4632,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../system/Images/Handlers/BaseHandler.php
|
path: ../../system/Images/Handlers/BaseHandler.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../system/Images/Handlers/BaseHandler.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:calcAspectRatio\(\) return type has no value type specified in iterable type array\.$#'
|
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:calcAspectRatio\(\) return type has no value type specified in iterable type array\.$#'
|
||||||
count: 1
|
count: 1
|
||||||
@ -4647,11 +4642,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../system/Images/Handlers/BaseHandler.php
|
path: ../../system/Images/Handlers/BaseHandler.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../system/Images/Handlers/BaseHandler.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Property CodeIgniter\\Images\\Handlers\\BaseHandler\:\:\$supportTransparency type has no value type specified in iterable type array\.$#'
|
message: '#^Property CodeIgniter\\Images\\Handlers\\BaseHandler\:\:\$supportTransparency type has no value type specified in iterable type array\.$#'
|
||||||
count: 1
|
count: 1
|
||||||
@ -4662,11 +4652,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../system/Images/Handlers/BaseHandler.php
|
path: ../../system/Images/Handlers/BaseHandler.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../system/Images/Handlers/ImageMagickHandler.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:process\(\) return type has no value type specified in iterable type array\.$#'
|
message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:process\(\) return type has no value type specified in iterable type array\.$#'
|
||||||
count: 1
|
count: 1
|
||||||
@ -4677,11 +4662,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../system/Images/Image.php
|
path: ../../system/Images/Image.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Method CodeIgniter\\Images\\ImageHandlerInterface\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
|
|
||||||
count: 1
|
|
||||||
path: ../../system/Images/ImageHandlerInterface.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method CodeIgniter\\Language\\Language\:\:formatMessage\(\) has parameter \$message with no value type specified in iterable type array\.$#'
|
message: '#^Method CodeIgniter\\Language\\Language\:\:formatMessage\(\) has parameter \$message with no value type specified in iterable type array\.$#'
|
||||||
count: 1
|
count: 1
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
# total 1 error
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: '#^Cannot unset offset string on list\<int\>\|null\.$#'
|
|
||||||
count: 2
|
|
||||||
path: ../../system/Test/Mock/MockCache.php
|
|
Loading…
x
Reference in New Issue
Block a user