Webservices request gets reply 'Class "DonationHelper" not found''

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 139
Joined: Tue Feb 28, 2006 3:23 pm

Webservices request gets reply 'Class "DonationHelper" not found''

Post by davidascher » Sun Apr 14, 2024 8:38 pm

JoomDonation is a 3rd party extension and "DonationHelper" comes with that extension. Since a recent update to that extension I've been unable to use Webservices on the site - get this message
Class "DonationHelper" not found

JoomDonation (com_jdonation) does not implement any Webservices. I can't see how a webservices request could possibly get tangled up with com_jdonation. The com_jdonation directory under api/components is EMPTY.

Does anybody have any suggestions for how to track down the source of this problem?

thank you in advance.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17506
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by toivo » Sun Apr 14, 2024 10:07 pm

Turn on the option 'System Debug' in the System tab of the Global Configuration. Enable the plugin 'System - Debug'. Those settings will hopefully give a more detailed message that will identify the script where the error occurs and display the PHP call stack, the classes and function calls leading to the error.
Toivo Talikka, Global Moderator

davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 139
Joined: Tue Feb 28, 2006 3:23 pm

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by davidascher » Mon Apr 15, 2024 12:39 am

I had already tried that. I see nothing at all reported in the site error_log file when I get that response. Apparently it isn't an "error".

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17506
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by toivo » Mon Apr 15, 2024 1:29 am

Then the origin of the error could simply be the script that calls the Joomla core API through web services. Does that script create its own class map?
Toivo Talikka, Global Moderator

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2962
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by SharkyKZ » Mon Apr 15, 2024 5:19 am

Report to developer or post contents of administrator/components/com_jdonation/loader.php file.

davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 139
Joined: Tue Feb 28, 2006 3:23 pm

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by davidascher » Mon Apr 15, 2024 11:11 am

toivo wrote:
Mon Apr 15, 2024 1:29 am
Then the origin of the error could simply be the script that calls the Joomla core API through web services. Does that script create its own class map?
I'm using Postman. I intended to mention that in the original post, but that detail somehow got lost.

davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 139
Joined: Tue Feb 28, 2006 3:23 pm

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by davidascher » Mon Apr 15, 2024 11:24 am

SharkyKZ wrote:
Mon Apr 15, 2024 5:19 am
Report to developer or post contents of administrator/components/com_jdonation/loader.php file.
administrator/components/com_jdonation/loader.php

Code: Select all

<?php

/**
 * @version        5.6.0
 * @package        Joomla
 * @subpackage     Joom Donation
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2009 - 2024 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */
defined('_JEXEC') or die();
use Joomla\CMS\Factory;
/**
 * Reregister prefix and classes for auto-loading
 */

JLoader::registerPrefix('OSF', JPATH_ADMINISTRATOR . '/components/com_jdonation/libraries/osf', false, true);
JLoader::registerPrefix('Donation', JPATH_BASE . '/components/com_jdonation',false, true);
JLoader::register('os_payments', JPATH_ROOT . '/components/com_jdonation/payments/os_payments.php');
JLoader::register('os_payment', JPATH_ROOT . '/components/com_jdonation/payments/os_payment.php');

if (Factory::getApplication()->isClient('administrator'))
{
        JLoader::register('DonationHelper', JPATH_ROOT . '/components/com_jdonation/helper/helper.php');
        JLoader::register('DonationHelperHtml', JPATH_ROOT . '/components/com_jdonation/helper/html.php');
        JLoader::register('DonationHelperBootstrap', JPATH_ROOT . '/components/com_jdonation/helper/bootstrap.php');
        JLoader::register('DonationHelperCryptor', JPATH_ROOT . '/components/com_jdonation/helper/cryptor.php');

        // Register override classes
        $possibleOverrides = [
                'DonationHelperOverrideHelper'       => 'helper.php',
        ];

        foreach ($possibleOverrides as $className => $filename)
        {
                JLoader::register($className, JPATH_ROOT . '/components/com_jdonation/helper/override/' . $filename);
        }
}
else
{
        //Front-end, we will re-use some controllers and models from back-end
        JLoader::register('DonationControllerDonor', JPATH_ADMINISTRATOR . '/components/com_jdonation/controller/donor.php');
        JLoader::register('DonationModelCampaigns', JPATH_ADMINISTRATOR . '/components/com_jdonation/model/campaigns.php');
        JLoader::register('DonationModelDonors', JPATH_ADMINISTRATOR . '/components/com_jdonation/model/donors.php');
        JLoader::register('DonationModelPlugins', JPATH_ADMINISTRATOR . '/components/com_jdonation/model/plugins.php');
}


if (DonationHelper::isJoomla5())
{
        JLoader::registerAlias('JDatabaseQuery', \Joomla\Database\DatabaseQuery::class);

        // Force autoload class to make it available for using
        class_exists('JDatabaseQuery');
}

if (version_compare(JVERSION, '4.0.0-dev', 'ge'))
{
        $db = Factory::getDbo();
        $db->setQuery("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
        $db->execute();
}


class JoomdonationHelper extends DonationHelper
{

}

The difference between this version of this file and the prior version as displayed by diff is

Code: Select all

<  * @copyright      Copyright (C) 2009 - 2024 Ossolution Team
---
>  * @copyright      Copyright (C) 2009 - 2023 Ossolution Team
28,37d27
<
<       // Register override classes
<       $possibleOverrides = [
<               'DonationHelperOverrideHelper'       => 'helper.php',
<       ];
<
<       foreach ($possibleOverrides as $className => $filename)
<       {
<               JLoader::register($className, JPATH_ROOT . '/components/com_jdonation/helper/override/' . $filename);
<       }
It's gibberish to me, but from a "black box" perspective it does look a little suspicious that it's all about the Helper. However, I still don't understand how a webservices call could ever get to this file - or any file in this component.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2962
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by SharkyKZ » Mon Apr 15, 2024 4:47 pm

Try changing this line:

Code: Select all

if (Factory::getApplication()->isClient('administrator'))
to this:

Code: Select all

if (!Factory::getApplication()->isClient('site'))

User avatar
Kubik-Rubik
Joomla! Explorer
Joomla! Explorer
Posts: 272
Joined: Wed Aug 25, 2010 1:59 pm
Location: Karlsruhe - Germany
Contact:

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by Kubik-Rubik » Mon Apr 15, 2024 7:42 pm

davidascher wrote:
Mon Apr 15, 2024 11:24 am
However, I still don't understand how a webservices call could ever get to this file - or any file in this component.
Hey David,

Components in the API call do trigger plugin events. If a plugin from this extension (e.g., a content plugin for the article component) is listening to the called event (e.g., onContentPrepare event), then it is loaded, and it can do many incomprehensible things, like calling classes that were not loaded correctly.

Try to disable plugins from the mentioned extension and rerun your API call.
Cheers
Viktor

Kubik-Rubik Joomla! Extensions https://kubik-rubik.de
Former member of Joomla! Production Leadership Team, Security Strike Team and Bug Squash Team

davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 139
Joined: Tue Feb 28, 2006 3:23 pm

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by davidascher » Mon Apr 15, 2024 8:30 pm

SharkyKZ wrote:
Mon Apr 15, 2024 4:47 pm
Try changing this line:

Code: Select all

if (Factory::getApplication()->isClient('administrator'))
to this:

Code: Select all

if (!Factory::getApplication()->isClient('site'))
That did the trick! I hope I can fix something for you someday!

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2962
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by SharkyKZ » Mon Apr 15, 2024 8:44 pm

By the way, should report this issue to the developer, if you haven't done that already. Otherwise your changes will be lost on update.

User avatar
Kubik-Rubik
Joomla! Explorer
Joomla! Explorer
Posts: 272
Joined: Wed Aug 25, 2010 1:59 pm
Location: Karlsruhe - Germany
Contact:

Re: Webservices request gets reply 'Class "DonationHelper" not found''

Post by Kubik-Rubik » Mon Apr 15, 2024 8:50 pm

Maybe just a quick explanation of why this solved the problem:

If the call is triggered via API, the application client name is api. In the initial check, the first condition is never met, and the registration of the called classes is skipped. In the proposed solution, the check is against the second condition, so the client name api does meet the first condition, and the required classes are registered.
Cheers
Viktor

Kubik-Rubik Joomla! Extensions https://kubik-rubik.de
Former member of Joomla! Production Leadership Team, Security Strike Team and Bug Squash Team


Post Reply

Return to “Joomla! 5.x Coding”