Skip to content

Commit

Permalink
Enforce non-null string in qtranxf_split (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
herrvigg committed Apr 10, 2023
1 parent 7dbd781 commit 17b43b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ function qtrans_getSortedLanguages( bool $reverse = false ): array {
if ( ! function_exists( 'qtrans_join' ) ) {
function qtrans_join( $texts ): string {
if ( ! is_array( $texts ) ) {
$texts = qtranxf_split( $texts );
$texts = qtranxf_split( $texts ?? '' );
}

return qtranxf_join_b( $texts );
}
}
if ( ! function_exists( 'qtrans_split' ) ) {
function qtrans_split( $text, bool $quicktags = true ): array {
return qtranxf_split( $text );
return qtranxf_split( $text ?? '' );
}
}
if ( ! function_exists( 'qtrans_use' ) ) {
Expand Down
6 changes: 3 additions & 3 deletions src/language_blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function qtranxf_get_language_blocks( $text ): array {

/**
* Split a multilingual string into array of tokens by language.
* If the string is empty or non-multilingual, it is repeated for each language.
*
* @param string $text multilingual string.
* @param string $text String that can contain multilingual tokens.
*
* @return string[] array of string items indexed by language.
*/
function qtranxf_split( $text ): array {
function qtranxf_split( string $text ): array {
$blocks = qtranxf_get_language_blocks( $text );

return qtranxf_split_blocks( $blocks );
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/acf/extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function encode_language_values( array $values ): string {
* @return array
*/
public static function decode_language_values( ?string $values ): array {
return qtranxf_split( $values );
return qtranxf_split( $values ?? '' );
}

/**
Expand Down

0 comments on commit 17b43b5

Please sign in to comment.