@@ -770,7 +770,7 @@ function backdrop_parse_url($url) {
770770 * The encoded path.
771771 */
772772function backdrop_encode_path ($ path ) {
773- return str_replace ('%2F ' , '/ ' , rawurlencode ($ path ));
773+ return str_replace ('%2F ' , '/ ' , rawurlencode (( string ) $ path ));
774774}
775775
776776/**
@@ -1102,7 +1102,7 @@ function backdrop_http_request($url, array $options = array()) {
11021102 // or PUT request. Some non-standard servers get confused by Content-Length in
11031103 // at least HEAD/GET requests, and Squid always requires Content-Length in
11041104 // POST/PUT requests.
1105- $ content_length = strlen ($ options ['data ' ]);
1105+ $ content_length = strlen (( string ) $ options ['data ' ]);
11061106 if ($ content_length > 0 || $ options ['method ' ] == 'POST ' || $ options ['method ' ] == 'PUT ' ) {
11071107 $ options ['headers ' ]['Content-Length ' ] = $ content_length ;
11081108 }
@@ -1178,7 +1178,7 @@ function backdrop_http_request($url, array $options = array()) {
11781178 $ result ->headers = array ();
11791179
11801180 // Parse the response headers.
1181- while ($ line = trim (array_shift ($ response ))) {
1181+ while ($ line = trim (( string ) array_shift ($ response ))) {
11821182 list ($ name , $ value ) = explode (': ' , $ line , 2 );
11831183 $ name = strtolower ($ name );
11841184 if (isset ($ result ->headers [$ name ]) && $ name == 'set-cookie ' ) {
@@ -1825,6 +1825,7 @@ function filter_xss($string, $allowed_tags = NULL) {
18251825 if (!backdrop_validate_utf8 ($ string )) {
18261826 return '' ;
18271827 }
1828+ $ string = (string ) $ string ;
18281829 // Store the text format.
18291830 _filter_xss_split ($ allowed_tags , TRUE );
18301831 // Remove NULL characters (ignored by some browsers).
@@ -2380,7 +2381,7 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) {
23802381 $ key = explode ('| ' , $ key );
23812382 if ($ interval >= $ value ) {
23822383 $ output .= ($ output ? ' ' : '' ) . format_plural (floor ($ interval / $ value ), $ key [0 ], $ key [1 ], array (), array ('langcode ' => $ langcode ));
2383- $ interval %= $ value ;
2384+ $ interval = ( int ) $ interval % $ value ;
23842385 $ granularity --;
23852386 }
23862387
@@ -2649,7 +2650,7 @@ function url($path = NULL, array $options = array()) {
26492650 // Strip leading slashes from internal paths to prevent them becoming external
26502651 // URLs without protocol. /example.com should not be turned into
26512652 // //example.com.
2652- $ path = ltrim ($ path , '/ ' );
2653+ $ path = ltrim (( string ) $ path , '/ ' );
26532654
26542655 global $ base_url , $ base_secure_url , $ base_insecure_url ;
26552656
@@ -2686,7 +2687,7 @@ function url($path = NULL, array $options = array()) {
26862687 }
26872688
26882689 $ base = $ options ['absolute ' ] ? $ options ['base_url ' ] . '/ ' : base_path ();
2689- $ prefix = empty ($ path ) ? rtrim ($ options ['prefix ' ], '/ ' ) : $ options ['prefix ' ];
2690+ $ prefix = empty ($ path ) ? rtrim (( string ) $ options ['prefix ' ], '/ ' ) : $ options ['prefix ' ];
26902691
26912692 // Cache the clean URLs setting, as url() is called very frequently.
26922693 static $ backdrop_static_fast ;
@@ -2752,6 +2753,7 @@ function url($path = NULL, array $options = array()) {
27522753 * Boolean TRUE or FALSE, where TRUE indicates an external path.
27532754 */
27542755function url_is_external ($ path ) {
2756+ $ path = (string ) $ path ;
27552757 $ colonpos = strpos ($ path , ': ' );
27562758 // Some browsers treat \ as / so normalize to forward slashes.
27572759 $ path = str_replace ('\\' , '/ ' , $ path );
@@ -3300,7 +3302,8 @@ function backdrop_set_time_limit($time_limit) {
33003302 * The path to the requested item or an empty string if the item is not found.
33013303 */
33023304function backdrop_get_path ($ type , $ name ) {
3303- return dirname (backdrop_get_filename ($ type , $ name ));
3305+ $ path = (string ) backdrop_get_filename ($ type , $ name );
3306+ return dirname ($ path );
33043307}
33053308
33063309/**
@@ -3396,8 +3399,9 @@ function backdrop_css_defaults($data = NULL) {
33963399 * $options['preprocess'] should be only set to TRUE when a file is required for
33973400 * all typical visitors and most pages of a site. It is critical that all
33983401 * preprocessed files are added unconditionally on every page, even if the
3399- * files do not happen to be needed on a page. This is normally done by calling
3400- * backdrop_add_css() in a hook_init() implementation.
3402+ * files do not happen to be needed on a page. However, it is preferred that
3403+ * modules do not use this function, but declare CSS files intended for all
3404+ * pages in their .info file instead.
34013405 *
34023406 * Non-preprocessed files should only be added to the page when they are
34033407 * actually needed.
@@ -4525,8 +4529,9 @@ function backdrop_region_class($region) {
45254529 * $options['preprocess'] should be only set to TRUE when a file is required for
45264530 * all typical visitors and most pages of a site. It is critical that all
45274531 * preprocessed files are added unconditionally on every page, even if the
4528- * files are not needed on a page. This is normally done by calling
4529- * backdrop_add_js() in a hook_init() implementation.
4532+ * files are not needed on a page. However, it is preferred that modules do not
4533+ * use this function, but declare JS files intended for all pages in their
4534+ * .info file instead.
45304535 *
45314536 * Non-preprocessed files should only be added to the page when they are
45324537 * actually needed.
@@ -5655,6 +5660,9 @@ function backdrop_build_js_cache($files) {
56555660 return FALSE ;
56565661 }
56575662 }
5663+ if (!$ map ) {
5664+ $ map = array ();
5665+ }
56585666 $ map [$ key ] = $ uri ;
56595667 state_set ('js_cache_files ' , $ map );
56605668 }
@@ -8515,6 +8523,9 @@ function watchdog_severity_levels() {
85158523 * @see backdrop_implode_tags()
85168524 */
85178525function backdrop_explode_tags ($ tags ) {
8526+ if (empty ($ tags )) {
8527+ return array ();
8528+ }
85188529 // This regexp allows the following types of user input:
85198530 // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
85208531 $ regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x ' ;
@@ -8692,7 +8703,7 @@ function backdrop_parse_dependency($dependency) {
86928703
86938704 if (isset ($ matches ['patch ' ]) && ($ matches ['patch ' ] === '0 ' || $ matches ['patch ' ])) {
86948705 if ($ matches ['patch ' ] == 'x ' && $ matches ['minor ' ] !== 'x ' ) {
8695- // See comments above about "x" in minor.
8706+ // See comments above about "x" in minor.
86968707 // Same principle applies to patch in relation to minor.
86978708 if ($ op == '> ' || $ op == '<= ' ) {
86988709 $ matches ['minor ' ]++;
0 commit comments