× How To / General

Assistance Required for Compatibility Issue with Joomla 5.1, Moodle 4.5, and PHP

1 month 2 weeks ago
globaltefl
Posts: 3
More
Topic Author
Assistance Required for Compatibility Issue with Joomla 5.1, Moodle 4.5, and PHP #1
Dear Antonio,

I am currently using Joomdle with the following setup:
• Joomla 5.1
• Moodle 4.5
• PHP 8.3
• MariaDB Version 15.1
• Ubuntu 20.04

While running the 'Users' module of Joomdle, I encountered the following error:

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/clients/client0/web9/web/administrator/components/com_joomdle/helpers/content.php on line 520 Web services error: Invalid parameter value detected

The issue originates from empty strings being passed as arguments to the urlencode() function. The specific line in question is:

$data[] = urlencode($k) . '=' . urlencode($v);

I attempted debugging and discovered that the $postdata array being passed to the function format_postdata_for_curlcall($postdata) is either empty or contains a search key with an empty value:

Array ( [search] => ) Web services error: Invalid parameter value detected

Could you please provide guidance on the following points:
1 Is there any specific configuration required for the plugin to work properly with the versions of Joomla, Moodle, PHP, and MariaDB I am using?
2 Should I install any additional components on my Ubuntu 20.04 server to resolve this issue?
3 Is it necessary to modify the plugin's code to handle empty strings? If so, could you suggest the best way to adapt the function format_postdata_for_curlcall to avoid passing null or empty values to urlencode()?

I appreciate your assistance and any updates you may have regarding the compatibility of Joomdle with the latest software versions.

Thank you for your support.

Best regards,
John

Please Log in or Create an account to join the conversation.

1 month 2 weeks ago
Antonio Durán
Posts: 7815
More
Assistance Required for Compatibility Issue with Joomla 5.1, Moodle 4.5, and PHP #2
Hi.

Here's an updated code for that function:
    static function format_postdata_for_curlcall($postdata) {
        if (is_object($postdata)) {
            $postdata = (array) $postdata;
        }
        $data = array();
        foreach ($postdata as $k=>$v) {
            if (is_object($v)) {
                $v = (array) $v;
            }
            if (is_array($v)) {
                $currentdata = urlencode($k);
                JoomdleHelperContent::format_array_postdata_for_curlcall($v, $currentdata, $data);
            }  else {
                $data[] = urlencode($k ?? '').'='.urlencode($v ?? '');
            }
        }
        $convertedpostdata = implode('&', $data);
        return $convertedpostdata;
    }

I should release a new version, but I have been busy lately...

Please Log in or Create an account to join the conversation.

1 month 2 weeks ago
globaltefl
Posts: 3
More
Topic Author
Assistance Required for Compatibility Issue with Joomla 5.1, Moodle 4.5, and PHP #3
Dear Antonio,

Thank you so much for your prompt response and for providing the updated code. I truly appreciate the time and effort you dedicated to resolving this issue. Your support has been incredibly helpful, and I’m grateful for your assistance.

If I encounter any further questions or challenges, I’ll be sure to reach out. Thanks again for your excellent support!

Best regards,
John

Please Log in or Create an account to join the conversation.