@@ -83,7 +83,7 @@ function qa_post_is_by_user($post, $userid, $cookieid)
8383 if (@$ post ['userid ' ] || $ userid )
8484 return @$ post ['userid ' ] == $ userid ;
8585 elseif (@$ post ['cookieid ' ])
86- return strcmp ( $ post ['cookieid ' ], $ cookieid ) == 0 ;
86+ return $ post ['cookieid ' ] === $ cookieid ;
8787
8888 return false ;
8989}
@@ -209,6 +209,10 @@ function qa_tag_html($tag, $microdata = false, $favorited = false)
209209 */
210210function qa_category_path ($ navcategories , $ categoryid )
211211{
212+ if ($ categoryid === null ) {
213+ return array ();
214+ }
215+
212216 $ upcategories = array ();
213217
214218 for ($ upcategory = @$ navcategories [$ categoryid ]; isset ($ upcategory ); $ upcategory = @$ navcategories [$ upcategory ['parentid ' ]])
@@ -266,7 +270,7 @@ function qa_ip_anchor_html($ip, $anchorhtml = null)
266270{
267271 if (qa_to_override (__FUNCTION__ )) { $ args =func_get_args (); return qa_call_override (__FUNCTION__ , $ args ); }
268272
269- if (!strlen ($ anchorhtml ))
273+ if (!strlen (( string ) $ anchorhtml ))
270274 $ anchorhtml = qa_html ($ ip );
271275
272276 return '<a href=" ' . qa_path_html ('ip/ ' . $ ip ) . '" title=" ' . qa_lang_html_sub ('main/ip_address_x ' , qa_html ($ ip )) . '" class="qa-ip-link"> ' . $ anchorhtml . '</a> ' ;
@@ -432,7 +436,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
432436 // Voting stuff
433437
434438 if (@$ options ['voteview ' ]) {
435- $ voteview = $ options ['voteview ' ];
439+ $ voteview = ( string ) $ options ['voteview ' ];
436440
437441 // Calculate raw values and pass through
438442
@@ -573,7 +577,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
573577 if (@$ options ['whatview ' ]) {
574578 $ fields ['what ' ] = qa_lang_html ($ isquestion ? 'main/asked ' : ($ isanswer ? 'main/answered ' : 'main/commented ' ));
575579
576- if (@$ options ['whatlink ' ] && strlen (@ $ options ['q_request ' ])) {
580+ if (@$ options ['whatlink ' ] && strlen ($ options ['q_request ' ] ?? '' )) {
577581 $ fields ['what_url ' ] = $ post ['basetype ' ] == 'Q '
578582 ? qa_path_html ($ options ['q_request ' ])
579583 : qa_path_html ($ options ['q_request ' ], array ('show ' => $ postid ), null , null , qa_anchor ($ post ['basetype ' ], $ postid ));
@@ -754,7 +758,7 @@ function qa_who_to_html($isbyuser, $postuserid, $usershtml, $ip = null, $microda
754758 if (isset ($ postuserid ) && isset ($ usershtml [$ postuserid ])) {
755759 $ whohtml = $ usershtml [$ postuserid ];
756760 } else {
757- if (strlen ($ name ))
761+ if (strlen (( string ) $ name ))
758762 $ whohtml = qa_html ($ name );
759763 elseif ($ isbyuser )
760764 $ whohtml = qa_lang_html ('main/me ' );
@@ -1293,7 +1297,7 @@ function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null)
12931297{
12941298 if (qa_to_override (__FUNCTION__ )) { $ args =func_get_args (); return qa_call_override (__FUNCTION__ , $ args ); }
12951299
1296- $ hascategory = strlen ($ categoryrequest );
1300+ $ hascategory = strlen (( string ) $ categoryrequest );
12971301
12981302 $ htmlmessage = $ hascategory ? qa_lang_html ('main/suggest_category_qs ' ) :
12991303 ($ usingtags ? qa_lang_html ('main/suggest_qs_tags ' ) : qa_lang_html ('main/suggest_qs ' ));
@@ -1326,7 +1330,7 @@ function qa_html_suggest_ask($categoryid = null)
13261330 $ htmlmessage ,
13271331
13281332 array (
1329- '^1 ' => '<a href=" ' . qa_path_html ('ask ' , strlen ($ categoryid ) ? array ('cat ' => $ categoryid ) : null ) . '"> ' ,
1333+ '^1 ' => '<a href=" ' . qa_path_html ('ask ' , strlen (( string ) $ categoryid ) ? array ('cat ' => $ categoryid ) : null ) . '"> ' ,
13301334 '^2 ' => '</a> ' ,
13311335 )
13321336 );
@@ -1723,7 +1727,7 @@ function qa_get_tags_field_value($fieldname)
17231727{
17241728 require_once QA_INCLUDE_DIR . 'util/string.php ' ;
17251729
1726- $ text = qa_remove_utf8mb4 (qa_post_text ($ fieldname ));
1730+ $ text = qa_remove_utf8mb4 (( string ) qa_post_text ($ fieldname ));
17271731
17281732 if (qa_opt ('tag_separator_comma ' ))
17291733 return array_unique (preg_split ('/\s*,\s*/ ' , trim (qa_strtolower (strtr ($ text , '/ ' , ' ' ))), -1 , PREG_SPLIT_NO_EMPTY ));
@@ -1796,21 +1800,21 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
17961800 $ depth ++; // to count category itself
17971801
17981802 foreach ($ navcategories as $ navcategory ) // now get siblings and self
1799- if (!strcmp ($ navcategory ['parentid ' ], $ category ['parentid ' ]))
1803+ if (!strcmp ($ navcategory ['parentid ' ] ?? '' , $ category ['parentid ' ] ?? '' ))
18001804 $ keycategoryids [$ navcategory ['categoryid ' ]] = true ;
18011805 }
18021806
18031807 if ($ depth < $ maxdepth )
18041808 foreach ($ navcategories as $ navcategory ) // now get children, if not too deep
1805- if (!strcmp ($ navcategory ['parentid ' ], $ categoryid ))
1809+ if (!strcmp ($ navcategory ['parentid ' ] ?? '' , $ categoryid ?? '' ))
18061810 $ keycategoryids [$ navcategory ['categoryid ' ]] = true ;
18071811
18081812 } else {
18091813 $ haschildren = false ;
18101814
18111815 foreach ($ navcategories as $ navcategory ) {
18121816 // check if it has any children
1813- if (!strcmp ($ navcategory ['parentid ' ], $ categoryid )) {
1817+ if (!strcmp ($ navcategory ['parentid ' ] ?? '' , $ categoryid ?? '' )) {
18141818 $ haschildren = true ;
18151819 break ;
18161820 }
@@ -1821,7 +1825,7 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
18211825 }
18221826
18231827 foreach ($ keycategoryids as $ keycategoryid => $ dummy )
1824- if (strcmp ($ keycategoryid , $ excludecategoryid ))
1828+ if (strcmp ($ keycategoryid , $ excludecategoryid ?? '' ))
18251829 $ field ['options ' ][$ keycategoryid ] = qa_category_path_html ($ navcategories , $ keycategoryid );
18261830
18271831 $ field ['value ' ] = @$ field ['options ' ][$ categoryid ];
@@ -1841,13 +1845,13 @@ function qa_get_category_field_value($fieldname)
18411845{
18421846 for ($ level = QA_CATEGORY_DEPTH ; $ level >= 1 ; $ level --) {
18431847 $ levelid = qa_post_text ($ fieldname . '_ ' . $ level );
1844- if (strlen ($ levelid ))
1848+ if (strlen (( string ) $ levelid ))
18451849 return $ levelid ;
18461850 }
18471851
18481852 if (!isset ($ levelid )) { // no Javascript-generated menu was present so take original menu
18491853 $ levelid = qa_post_text ($ fieldname . '_0 ' );
1850- if (strlen ($ levelid ))
1854+ if (strlen (( string ) $ levelid ))
18511855 return $ levelid ;
18521856 }
18531857
@@ -2008,7 +2012,7 @@ function qa_load_theme_class($theme, $template, $content, $request)
20082012
20092013 foreach ($ loadlayers as $ layer ) {
20102014 $ filename = $ layer ['directory ' ] . $ layer ['include ' ];
2011- $ layerphp = file_get_contents ($ filename );
2015+ $ layerphp = ( string ) file_get_contents ($ filename );
20122016
20132017 if (strlen ($ layerphp )) {
20142018 // include file name in layer class name to make debugging easier if there is an error
@@ -2185,7 +2189,7 @@ function qa_get_post_title($fieldname)
21852189{
21862190 require_once QA_INCLUDE_DIR . 'util/string.php ' ;
21872191
2188- return qa_remove_utf8mb4 (qa_post_text ($ fieldname ));
2192+ return qa_remove_utf8mb4 (( string ) qa_post_text ($ fieldname ));
21892193}
21902194
21912195/**
@@ -2247,7 +2251,7 @@ function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = fal
22472251 require_once QA_INCLUDE_DIR . 'util/image.php ' ;
22482252 require_once QA_INCLUDE_DIR . 'app/users.php ' ;
22492253
2250- if (strlen ($ blobId ) == 0 || (int )$ size <= 0 ) {
2254+ if (strlen (( string ) $ blobId ) == 0 || (int )$ size <= 0 ) {
22512255 return null ;
22522256 }
22532257
0 commit comments