No Code Attached Yet bug
avatar dmb0058
dmb0058
1 Jan 2023

Steps to reproduce the issue

Code attached in file below, JApplicationCli invocation works, JApplicationDaemon throws exception.

Expected result

$ php test.php
pages: 1

Actual result

$ php test.php -d

PHP Warning:  pcntl_signal(): Specified handler "DaemonApplication::signal" is not callable (class 'DaemonApplication' not found) in /var/www/game.conlucra.com/public_html/libraries/src/Application/DaemonApplication.php on line 886

System information (as much as possible)

PHP Built On	Linux ip-172-30-2-137 5.15.0-1026-aws #30-Ubuntu SMP Wed Nov 23 14:15:21 UTC 2022 x86_64
Database Type	mysql
Database Version	8.0.31-0ubuntu0.22.04.1
Database Collation	utf8mb4_0900_ai_ci
Database Connection Collation	utf8mb4_0900_ai_ci
PHP Version	7.4.32
Web Server	Apache/2.4.52 (Ubuntu)
WebServer to PHP Interface	apache2handler
Joomla! Version	Joomla! 3.10.11 Stable [ Daraja ] 14-August-2022 14:18 GMT
Joomla! Platform Version	Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent	Mozilla/5.0 (Linux; Android 10; SM-G960U1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Mobile Safari/537.36

Additional comments

testCli.txt

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar dmb0058 dmb0058 - open - 1 Jan 2023
avatar dmb0058 dmb0058 - change - 1 Jan 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 1 Jan 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Jan 2023
avatar dmb0058
dmb0058 - comment - 1 Jan 2023

Incomplete code, apologies.

This is the correct code to reproduce:

<?php

const _JEXEC = 1;

if (file_exists(dirname(__DIR__) . '../../defines.php'))
    require_once dirname(__DIR__) . '../../defines.php';

if (!defined('_JDEFINES'))
{
    define('JPATH_BASE', dirname(__DIR__) . "/../..");
    require_once JPATH_BASE . '/includes/defines.php';
}

require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';

class LaunchCLI extends JApplicationCli
{
    public function doExecute()
    {   
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('COUNT(*) AS count')->from($db->quoteName('#__content'));
        $db->setQuery($query);
        $result = $db->loadObject();
        $this->out("pages: " . $result->count);
    }
}

class LaunchDaemon extends JApplicationDaemon
{
    public $name='test';

    public function doExecute()
    {   
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('COUNT(*) AS count')->from($db->quoteName('#__content'));
        $db->setQuery($query);
        $result = $db->loadObject();
        $this->out("pages: " . $result->count);
    }
}

$options = getopt("d");

try {
    if (array_key_exists('d', $options))
        JApplicationDaemon::getInstance('LaunchDaemon')->execute();
    else
        JApplicationCli::getInstance('LaunchCLI')->execute();
}
catch (Exception $e){
    echo $e->getMessage() . "\n";
}

?>

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39533.
avatar dmb0058 dmb0058 - change - 1 Jan 2023
The description was changed
avatar dmb0058 dmb0058 - edited - 1 Jan 2023
avatar dmb0058
dmb0058 - comment - 1 Jan 2023

Test scripttestCli.txt


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39533.

avatar dmb0058 dmb0058 - change - 1 Jan 2023
The description was changed
avatar dmb0058 dmb0058 - edited - 1 Jan 2023
avatar brianteeman
brianteeman - comment - 1 Jan 2023

Joomla 3 is now only getting security fixes

avatar dmb0058
dmb0058 - comment - 1 Jan 2023

NP, I assume it doesn't work on J4 either, I'll test and submit a new bug report ...

avatar brianteeman
brianteeman - comment - 7 Jan 2023

were you able to replicate this in joomla 4?

avatar dmb0058
dmb0058 - comment - 7 Jan 2023

No, I haven't had time, had to fall back on building a cli app/cron job to
get a reliable solution in place. The daemon is on the backlog, maybe after
we port the whole package to J4.

On Sat, 7 Jan 2023, 7:50 am Brian Teeman, @.***> wrote:

were you able to replicate this in joomla 4?


Reply to this email directly, view it on GitHub
#39533 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABDXCQNMZOH7K34MQ3ZSZKTWREN37ANCNFSM6AAAAAATOCRUDM
.
You are receiving this because you authored the thread.Message ID:
@.***>

avatar Fedik
Fedik - comment - 7 Jan 2023

I just looked the code, the issue valid for both J3 and j4.
DemonApplication sets incorrect class as signal handler.
Joomla 3

// Attach the signal handler for the signal.
if (!$this->pcntlSignal(constant($signal), array('DaemonApplication', 'signal')))
{
\JLog::add(sprintf('Unable to reroute signal handler: %s', $signal), \JLog::EMERGENCY);
return false;
}

Joomla 4

// Attach the signal handler for the signal.
if (!$this->pcntlSignal(\constant($signal), array('DaemonApplication', 'signal'))) {
Log::add(sprintf('Unable to reroute signal handler: %s', $signal), Log::EMERGENCY);
return false;
}

It should be full class name, with namespace.

avatar Fedik Fedik - change - 7 Jan 2023
Title
JApplicationDaemon can't find its own class
JApplicationDaemon can't find its own class, DemonApplication sets incorrect class as signal handler.
avatar Fedik Fedik - edited - 7 Jan 2023
avatar Fedik Fedik - change - 7 Jan 2023
Labels Added: bug
avatar Fedik Fedik - labeled - 7 Jan 2023
avatar Hackwar Hackwar - change - 24 Nov 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-11-24 20:11:01
Closed_By Hackwar
avatar Hackwar Hackwar - close - 24 Nov 2024
avatar Hackwar
Hackwar - comment - 24 Nov 2024

I created #44518 to fix this. Since we have a PR, I'm closing this one. Thank you for reporting this!

avatar HLeithner HLeithner - change - 27 Nov 2024
The description was changed
avatar HLeithner HLeithner - edited - 27 Nov 2024

Add a Comment

Login with GitHub to post a comment