Skip to content

Promote warnings to errors in chunk_split() #4603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2194,8 +2194,8 @@ PHP_FUNCTION(chunk_split)
ZEND_PARSE_PARAMETERS_END();

if (chunklen <= 0) {
php_error_docref(NULL, E_WARNING, "Chunk length should be greater than zero");
RETURN_FALSE;
zend_throw_error(NULL, "Chunk length should be greater than zero");
return;
}

if ((size_t)chunklen > ZSTR_LEN(str)) {
Expand Down
Binary file modified ext/standard/tests/strings/chunk_split_variation5.phpt
Binary file not shown.
14 changes: 5 additions & 9 deletions ext/standard/tests/strings/chunk_split_variation8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ for($count = 0; $count < count($values); $count++) {
var_dump( chunk_split($heredoc_str, $values[$count], $ending) );
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (\Error $e) {
echo $e->getMessage() . "\n";
}
}

Expand All @@ -58,18 +60,14 @@ echo "Done"
--EXPECTF--
*** Testing chunk_split() : different 'chunklen' with heredoc 'str' ***
-- Iteration 1 --

Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
bool(false)
Chunk length should be greater than zero
-- Iteration 2 --
string(504) "T:::h:::i:::s:::':::s::: :::h:::e:::r:::e:::d:::o:::c::: :::s:::t:::r:::i:::n:::g::: :::w:::i:::t:::h::: ::: ::: :::a:::n:::d::: :::
::: :::w:::h:::i:::t:::e::: :::s:::p:::a:::c:::e::: :::c:::h:::a:::r:::.:::
:::I:::t::: :::h:::a:::s::: :::_:::s:::p:::e:::c:::i:::@:::l::: :::c:::h:::@:::r:::$::: :::2:::2:::2:::2::: :::!:::!:::!:::N:::o:::w::: :::\:::k::: :::a:::s::: :::e:::s:::c:::a:::p:::e::: :::c:::h:::a:::r::: :::t:::o::: :::t:::e:::s:::t:::
:::c:::h:::u:::n:::k:::_:::s:::p:::l:::i:::t:::(:::):::"
-- Iteration 3 --

Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
bool(false)
Chunk length should be greater than zero
-- Iteration 4 --
string(129) "This's heredoc string with and
white space char.
Expand All @@ -88,7 +86,5 @@ chunk_split():::"
-- Iteration 7 --
chunk_split() expects parameter 2 to be int, float given
-- Iteration 8 --

Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
bool(false)
Chunk length should be greater than zero
Done