FTP function getClient is using old parse_str method. #1008

Closed
opened 2023-09-15 22:13:25 +00:00 by Tom van der Laan · 1 comment

Steps to reproduce the issue

Compile component with add to sales server set to yes in php 8.x

Expected result

Compile succesfull.

Actual result

Fatal error on parse_str function.

System information (as much as possible)

  • OS Name & Version:
  • MySql Version:
  • Apache Version:
  • PHP Version:
  • Joomla Version:
  • JCB Version:
  • Browser:

Additional comments

FILE: /libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Server/Ftp.php

### Steps to reproduce the issue Compile component with add to sales server set to yes in php 8.x ### Expected result Compile succesfull. ### Actual result Fatal error on parse_str function. ### System information (as much as possible) - OS Name & Version: - MySql Version: - Apache Version: - PHP Version: - Joomla Version: - JCB Version: - Browser: ### Additional comments FILE: /libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Server/Ftp.php
Author
Member

Fixed it by editing the function like this:

	private function getClient(): ?FtpClient
	{
		// make sure we have a string and it is not default or empty
 		if (StringHelper::check($this->details->signature))
		{
			// turn into variables
 			$signature = [];
			parse_str((string) $this->details->signature, $signature);
			// set options
 			if (isset($signature['options']) && ArrayHelper::check($signature['options']))
			{
				foreach ($options as $o__p0t1on => $vAln3)
				{
					if ('timeout' === $o__p0t1on)
					{
						$options[$o__p0t1on] = (int) $vAln3;
					}
					if ('type' === $o__p0t1on)
					{
						$options[$o__p0t1on] = (string) $vAln3;
					}
				}
			}
			else
			{
				$options = [];
			}
			// get ftp object
 			if (isset($signature['host']) && $signature['host'] != 'HOSTNAME' &&
				isset($signature['port']) && $signature['port'] != 'PORT_INT' &&
				isset($signature['username']) && $signature['username'] != 'user@name.com' &&
				isset($signature['password']) && $signature['password'] != 'password')
			{
				// this is a singleton
 				return FtpClient::getInstance($host, $port, $options, $username, $password);
			}
		}

 		return null;
	}

Fixed it by editing the function like this: ``` private function getClient(): ?FtpClient { // make sure we have a string and it is not default or empty if (StringHelper::check($this->details->signature)) { // turn into variables $signature = []; parse_str((string) $this->details->signature, $signature); // set options if (isset($signature['options']) && ArrayHelper::check($signature['options'])) { foreach ($options as $o__p0t1on => $vAln3) { if ('timeout' === $o__p0t1on) { $options[$o__p0t1on] = (int) $vAln3; } if ('type' === $o__p0t1on) { $options[$o__p0t1on] = (string) $vAln3; } } } else { $options = []; } // get ftp object if (isset($signature['host']) && $signature['host'] != 'HOSTNAME' && isset($signature['port']) && $signature['port'] != 'PORT_INT' && isset($signature['username']) && $signature['username'] != 'user@name.com' && isset($signature['password']) && $signature['password'] != 'password') { // this is a singleton return FtpClient::getInstance($host, $port, $options, $username, $password); } } return null; } ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1008
No description provided.