From 3233c6fcb385c2482127745e3f85a99aea23a4fa Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sat, 5 Nov 2022 07:37:46 +1100 Subject: [PATCH] add cron recipe to lando configs --- .lando.yml | 8 ++++++++ .lando/cron-helper.sh | 11 +++++++++++ .lando/cron.txt | 1 + Code/Lib/Channel.php | 4 ++-- Code/Lib/Libzot.php | 2 +- Code/Module/Settings/Channel.php | 9 +++------ 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .lando/cron-helper.sh create mode 100644 .lando/cron.txt diff --git a/.lando.yml b/.lando.yml index 1c70a360e..f8af5fb8a 100644 --- a/.lando.yml +++ b/.lando.yml @@ -22,6 +22,14 @@ services: XDEBUG_SESSION_START: lando config: php: .vscode/php.ini + build_as_root: + - apt-get update -y + - apt-get install cron -y + - cp -f /app/.lando/cron-helper.sh /usr/local/bin/docker-php-entrypoint + run_as_root: + - service cron start + run: + - crontab /app/.lando/cron.txt proxy: mailservice: - mail.lndo.site diff --git a/.lando/cron-helper.sh b/.lando/cron-helper.sh new file mode 100644 index 000000000..66b0586d7 --- /dev/null +++ b/.lando/cron-helper.sh @@ -0,0 +1,11 @@ +#!/bin/sh +service cron start + +set -e + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- apache2-foreground "$@" +fi + +exec "$@" diff --git a/.lando/cron.txt b/.lando/cron.txt new file mode 100644 index 000000000..cff178990 --- /dev/null +++ b/.lando/cron.txt @@ -0,0 +1 @@ +*/10 * * * * cd /app; /usr/local/bin/php Code/Daemon/Run.php Cron > /dev/null 2>&1 diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index b5401f312..cc5cb2d1d 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -243,9 +243,9 @@ class Channel /** * @brief Return the total number of channels on this site. * - * No filtering is performed except to check PAGE_REMOVED. + * No filtering is performed except to check channel_removed. * - * @returns int|booleean + * @returns int|bool * on error returns boolean false */ public static function channel_total() diff --git a/Code/Lib/Libzot.php b/Code/Lib/Libzot.php index a87bcb45c..a250308e1 100644 --- a/Code/Lib/Libzot.php +++ b/Code/Lib/Libzot.php @@ -296,7 +296,7 @@ class Libzot * @param array $channel => local channel structure of target recipient, required for "friending" operations * @param array $force (optional) default false * - * @return boolean + * @return bool * * \b true if successful * * otherwise \b false */ diff --git a/Code/Module/Settings/Channel.php b/Code/Module/Settings/Channel.php index 96d4485ef..29df0a64d 100644 --- a/Code/Module/Settings/Channel.php +++ b/Code/Module/Settings/Channel.php @@ -30,15 +30,12 @@ class Channel public function post() { - $channel = App::get_channel(); check_form_security_token_redirectOnErr('/settings', 'settings'); Hook::call('settings_post', $_POST); - $set_perms = ''; - $role = ((x($_POST, 'permissions_role')) ? notags(trim($_POST['permissions_role'])) : ''); $oldrole = get_pconfig(local_channel(), 'system', 'permissions_role'); @@ -47,7 +44,7 @@ class Channel $role = $oldrole; } - if (($role != $oldrole) || ($role === 'custom')) { + if (($role !== $oldrole) || ($role === 'custom')) { $this->change_permissions_role($channel, $role); } @@ -177,9 +174,9 @@ class Channel set_pconfig(local_channel(), 'system', 'noindex', $noindex); set_pconfig(local_channel(), 'system', 'preview_outbox', $preview_outbox); - $r = q( - "update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d", + "update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', + channel_notifyflags = %d, channel_max_friend_req = %d, channel_expire_days = %d where channel_id = %d", dbesc($username), intval($pageflags), dbesc($timezone),