Skip to content

PHP Fatal error: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int #92

@barsch

Description

@barsch
  • Multisite environment (ca. 30 subsites)
  • Cron runs every 30 min
  • automatic publishing of scheduled post stopped working at some point this year
  • running cron.sh manually throws "PHP Fatal error" for subsites with scheduled posts
PHP Fatal error:  Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given in phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/cron-command/src/Cron_Event_Command.php:418
Stack trace:
#0 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(418): date()
#1 [internal function]: Cron_Event_Command::format_event()
#2 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(460): array_map()
#3 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(228): Cron_Event_Command::get_cron_events()
#4 [internal function]: Cron_Event_Command->run()
#5 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#6 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#7 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#8 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(419): WP_CLI\Dispatcher\Subcommand->invoke()
#9 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(442): WP_CLI\Runner->run_command()
#10 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1256): WP_CLI\Runner->run_command_and_exit()
#11 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#12 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process()
#13 phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#14 phar:///home/wordpress/bin/wp-cli.phar/php/boot-phar.php(11): include('...')
#15 /home/wordpress/bin/wp-cli.phar(4): include('...')
#16 {main}
  thrown in phar:///home/wordpress/bin/wp-cli.phar/vendor/wp-cli/cron-command/src/Cron_Event_Command.php on line 418
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

Wordpress / WP Cli environment

wordpress@kiste:~$ wp core version
6.1.1
wordpress@kiste:~$ wp --info
OS:     Linux 5.4.0-137-generic #154~18.04.1-Ubuntu SMP Tue Jan 10 16:58:20 UTC 2023 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php8.2
PHP version:    8.2.1
php.ini used:   /etc/php/8.2/cli/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/wordpress
WP-CLI packages dir:
WP-CLI cache dir:       /home/wordpress/.wp-cli/cache
WP-CLI global config:   /home/wordpress/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.7.1

cron.sh

#!/bin/bash

WP_BIN="/home/wordpress/bin/wp";
WP_PATH="/home/wordpress/www";

for SITE_URL in $($WP_BIN site list --fields=domain,path,archived,deleted --format=csv --path="$WP_PATH" | grep ",0,0$" | awk -F ',' '{print $1 $2}');
do
  echo
  echo $SITE_URL
  $WP_BIN cron event run --due-now --url="$SITE_URL" --path="$WP_PATH";
done

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions