back to phpList.org

phpList cli "-p processqueue" does nothing, fails at languages.php @session_start();


#1

Can someone help me debug why – when I attempt to process the phplist queue via the cli – I get no output at all?

I’m attempting to process the phplist queue with the following command:

[maltfield@ose ~]$ sudo su -s /bin/bash apache -c "/usr/bin/php /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/index.php -c /var/www/html/phplist.opensourceecology.org/config.php -p processqueue"
[maltfield@ose ~]$ 

As you can see from the above output – there is no output. I’ve also confirmed that the queue is not being processed silently.

Fwiw, I have error reporting enabled with the following line on the public_html/lists/admin/index.php file:

$er = error_reporting(1);

I also have verbosity turned on via the config.php file:

define('VERBOSE', 1);

Moreover, I have defined MANUALLY_PROCESS_QUEUE & set $commandline_users in my config.php file:

// set this to 0, if you set up a cron to download bounces regularly by using the                                              
// commandline option. If this is 0, users cannot run the page from the web                                                    
// frontend. Read README.commandline to find out how to set it up on the                                                       
// commandline                                                                                                                 
define('MANUALLY_PROCESS_BOUNCES', 1);                                                                                         
                                                                                                                               
// we set MANUALLY_PROCESS_QUEUE to 0 so that the "Process the Queue" button                                                   
// will disappear from the WUI as the queue is processed via cron                                                              
define('MANUALLY_PROCESS_QUEUE', 0);                                                                                           
                                                                                                                               
// whitelist of users that are permitted to execute bin/phplist for cli control                                                
$commandline_users = array( "apache" );    

I have traced the end of the execution to the line in index.php where it include the ‘languages.php’ script https://github.com/phpList/phplist3/blob/3a3e9eaf5796353b67e94535a9e20de8ceb489e3/public_html/lists/admin/index.php#L100

include_once dirname(__FILE__).'/languages.php';

I further traced the end of the execution to the line “@session_start();” in the languages.php file

After that session_start() line, I cannot get a simple echo command to produce any output on the cli.

The only other description I’ve found about this issue was on the old forums from 2012. It had no responses.

Here’s some info about my system:

[root@ose admin]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@ose admin]# uname -a
Linux ose.opensourceecology.org 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@ose admin]# sudo su -s /bin/bash apache -c "/usr/bin/php -v"
PHP 5.6.33 (cli) (built: Jan 14 2018 08:07:11) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
[root@ose admin]# 
[root@ose admin]# cat /var/www/html/phplist.opensourceecology.org/VERSION 
# file that keeps track of the latest tag in cvs and the corresponding version
# this automates publishing a new version, when it's tagged
# if you don't understand this, don't worry. You don't need this file
VERSION=3.3.1
DEVVERSION=3.3.2

[root@ose admin]#

What does this “session_start()” call do?

Please help me debug why this session_start() line is breaking my ability to process the queue via the cli for a cron job.


#2

Possibly a permissions problem with the php session files. What does this command do regarding the “current user”?

Have you tried simply

sudo -u apache /usr/bin/php ....


#3

have you tried simply

sudo -u apache /usr/bin/php ....

So the simple sudo -u doesn’t work because the apache user’s shell is ‘/sbin/nologin’. But there is no issues calling php in this way:

[root@ose admin]# sudo su -s /bin/bash apache -c "/usr/bin/php -v"
PHP 5.6.33 (cli) (built: Jan 14 2018 08:07:11) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
[root@ose admin]# 

Possibly a permissions problem with the php session files.

My session config is slightly modified, but permissions should be fine. Since ‘/tmp’/ is world-read/writeable, I set ‘session.cookie_secure = “/var/lib/php/session”’. But the permissions are 0600 apache:apache for the session files:

[root@ose ~]# ls -lah /var/lib/php/session | head
total 1.4M
drwxrwx--- 2 root   apache 1.1M Feb 26 07:53 .
drwxr-xr-x 6 root   root   4.0K Mar 16  2018 ..
-rw------- 1 apache apache  14K Feb 25 05:51 sess_XX1
-rw------- 1 apache apache    0 Feb 26 07:51 sess_XX2
-rw------- 1 apache apache    0 Feb 26 07:51 sess_XX3
-rw------- 1 apache apache  16K Feb 24 19:54 sess_XX4
-rw------- 1 apache apache  14K Feb 24 19:30 sess_XX5
-rw------- 1 apache apache    0 Feb 26 07:50 sess_XX6
-rw------- 1 apache apache    0 Feb 26 07:51 sess_XX7
[root@ose ~]# 

Here’s some other session related options I’ve set in /etc/php.ini.

[root@ose ~]# grep -i 'session' /etc/php.ini | grep -vi "^;" | less
open_basedir = "...:/var/lib/php/session:..."
[Session]
session.use_strict_mode = 1
session.save_handler = files
session.use_cookies = 1
session.cookie_secure = "/var/lib/php/session"
session.use_only_cookies = 1
session.name = OSESESSION
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 1
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = sha512
session.hash_bits_per_character = 5

Any chance there’s some code someplace that expects the session name to be PHPSESSID?


#4

Solved! I had an error in my php.ini specifying the session dir as ‘session.cookie_secure’ instead of ‘session.save_path’

TIL that the “@” perpended to a function call suppresses errors. Why does phplist do this in the call to session_start() in languages.php?

If there’s no good reason, then I’d like to submit a PR to remove the “@” – I had both VERBOSITY defined to 1 & error_reporting enabled, and this character suppressed the error, making troubleshooting this unnecessarily difficult.

When I finally removed the ‘@’, I saw this error, which helped me pinpoint the issue:

[maltfield@ose ~]$ sudo su -s /bin/bash apache -c "/usr/bin/php /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/index.php -c /var/www/html/phplist.opensourceecology.org/config.php -p processqueue"
PHP Fatal error:  session_start(): Failed to initialize storage module: files (path: ) in /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/languages.php on line 57
PHP Stack trace:
PHP   1. {main}() /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/index.php:0
PHP   2. include_once() /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/index.php:102
PHP   3. session_start() /var/www/html/phplist.opensourceecology.org/public_html/lists/admin/languages.php:57
[maltfield@ose ~]$ 

Now I just need to figure out why it says there’s no subscribers for my “test” list with 3x subscribers…

[maltfield@ose ~]$ sudo su -s /bin/bash apache -c "/usr/bin/php /var/www/ht
ml/phplist.opensourceecology.org/public_html/lists/admin/index.php -c /var/www/h
tml/phplist.opensourceecology.org/config.php -p processqueue"                   
test1
phpList - phpList version 3.3.3 (c) 2000-2019 phpList Ltd, https://www.phplist.c
om                                                                              
phpList version 3.3.3 (c) 2000-2019 phpList Ltd, https://www.phplist.comphpList - Maximum time for queue processing: 99999 [0.0020190000] (107)                 
phpList - Recently sent : 0
phpList - Started [0.0029320000] (110)
phpList - Sending in batches of 1 emails [0.0001870000] (111)
phpList -  select id from phplist_message where status not in ("draft", "sent", "prepared", "suspended") and embargo  [0.0001720000] (112)                      
phpList - Processing has started, [0.0015950000] (115)
phpList - One campaign to process. [0.0013430000] (117)
phpList - sending of this campaign will stop, if it is still going in  3 days 21 hours 48 minutes 35 seconds [0.0032410000] (134)                               
phpList - Processing campaign 22 [0.0021890000] (141)
phpList - Looking for subscribers [0.0040380000] (146)
phpList - User select query select distinct u.id from phplist_listuser as listuser                                                                              
        inner join phplist_user_user as u ON u.id = listuser.userid
        inner join phplist_listmessage as listmessage ON listuser.listid = listmessage.listid                                                                   
        left join phplist_usermessage as um ON (um.messageid = 22 and um.userid = listuser.userid)                                                              
        where
        listmessage.messageid = 22
        and listmessage.listid = listuser.listid
        and u.id = listuser.userid
        and um.userid IS NULL
        and u.confirmed and !u.blacklisted and !u.disabled
          [0.0014990000] (149)
phpList - Found them: 0 to process [0.0018440000] (153)
phpList - Processed 0 out of 0 subscribers [0.0026690000] (156)
phpList - Hmmm, No subscribers found to send to [0.0013820000] (158)
phpList - It took  1 minutes 05 seconds to send this message [0.0029960000] (163)                                                                               
phpList - Script stage: 3 [0.0014470000] (166)
phpList - Finished, Nothing to do [0.0001490000] (167)
phpList - Finished, All done [0.0026200000] (172)
[maltfield@ose ~]$