conftest.php 1.5.2 svn 20230831 - Warning: Undefined variable $verify_peer, BUG in functions/imap_messages.php

David C Rankin <[email protected]> Thu, 31 Aug 2023 20:54:08 -0500
Newsgroups gmane.mail.squirrelmail.devel
Message-ID <[email protected]>
Hello sqmail devs,

   Happy to find the update squirrelmail that I can run on PHP8! (had been 
building 5.6 every time ICU changed for a while...). Normal setup, but I 
encountered a warning during src/conftest.php check that I thought I would 
pass on.

Server:

   Running on Archlinux: 6.4.12-arch1-1
   Apache/2.4.57 (Unix) OpenSSL/3.1.2 mod_fcgid/2.3.9 PHP/8.1.22
   postfix 3.8.1-3
   dovecot 2.3.20-2

   The PHP/8.1.22 is from the Archlinux php-legacy packages specifically held 
back to the 8.1 release to avoid nextcloud breakage. Arch packages 8.2 as php.

conftest.php warning:

<snip>
Warning: Undefined variable $verify_peer in 
/srv/http/htdocs/squirrelmail/src/configtest.php on line 746
verify_peer :
     IMAP server ready (* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID 
ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN] Dovecot ready.)
     Capabilities: * CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE 
IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN
Checking internationalization (i18n) settings...
      gettext - Gettext functions are unavailable. SquirrelMail will use 
slower internal gettext functions.
      mbstring - Mbstring functions are available.
      recode - Recode functions are unavailable.
      iconv - Iconv functions are available.
      timezone - Webmail users can change their time zone settings. Current 
time zone is UTC.
Checking database functions...
     not using database functionality.
Checking LDAP functions...
     not using LDAP functionality.
Summary

Congratulations, your SquirrelMail setup looks fine to me!

Login now

   Login works fine, but the normal area where the heading controls and 
messages are displayed is blank. The only error logged is:

[Thu Aug 31 20:43:42.072929 2023] [fcgid:warn] [pid 12712] [client 
192.168.6.104:56166] mod_fcgid: stderr: PHP Parse error:  syntax error, 
unexpected token "[" in 
/srv/http/htdocs/squirrelmail/functions/imap_messages.php on line 120, 
referer: https://2pi.3111skyline.com/squirrelmail/src/left_main.php

   That corresponds to the following line in sqimap_toggle_flag():

/**
  * Set a flag on the provided uid list
  * @param  resource imap connection
  * @param  mixed $id Normally an array which is a list with message UIDs to 
be flagged
  *                   or a string range such as "1:*" or a simple integer
  * @param  string $flag Flags to set/unset flags can be i.e.'\Seen', 
'\Answered', '\Seen \Answered'
  * @param  bool   $set  add (true) or remove (false) the provided flag
  * @param  bool   $handle_errors Show error messages in case of a NO, BAD or 
BYE response
  * @return array  $aMessageList array with messages containing the new flags 
and UID @see parseFetch
  */
function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) {
     $msgs_id = sqimap_message_list_squisher($id);
     $set_string = ($set ? '+' : '-');

     /*
     * We need to return the data in the same order as the caller supplied
     * in $id, but IMAP servers are free to return responses in
     * whatever order they wish... So we need to re-sort manually
     */
     $aMessageList = array();
     if (is_array($id)) {
         for ($i=0; $i<count($id); $i++) {
             $aMessageList[$id[$i]] = array();
         }
     }

     $aResponse = sqimap_run_command_list($imap_stream, "STORE $msgs_id 
".$set_string."FLAGS ($flag)", $handle_error
s, $response, $message, TRUE);

     // parse the fetch response
     $parseFetchResults=parseFetch($aResponse,$aMessageList);

     // some broken IMAP servers do not return UID elements on UID STORE
     // if this is the case, then we need to do a UID FETCH
     if (!empty($parseFetchResults)
      && !isset($parseFetchResults)['UID']) {
120  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         $aResponse = sqimap_run_command_list($imap_stream, "FETCH $msgs_id 
(FLAGS)", $handle_errors, $response, $me
ssage, TRUE);
         $parseFetchResults = parseFetch($aResponse,$aMessageList);
     }

     return ($parseFetchResults);
}

   The problem is the index ['UID'] is applied to 
!isset($parseFetchResults)['UID'] where it should be applied as 
!isset(($parseFetchResults)['UID']))

   Adding the paren solves that issue. Let me know on the warning.

-- 
David C. Rankin, J.D.,P.E.


-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [email protected]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel