Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method BufferStreamHandler::stream_register() #18075

Merged
merged 2 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions libraries/src/Client/FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Log\Log;
use Joomla\CMS\Utility\BufferStreamHandler;

/** Error Codes:
* - 30 : Unable to connect to host
Expand Down Expand Up @@ -153,11 +154,7 @@ public function __construct(array $options = array())

if (FTP_NATIVE)
{
// Import the generic buffer stream handler
\JLoader::import('joomla.utilities.buffer');

// Autoloading fails for JBuffer as the class is used as a stream handler
\JLoader::load('JBuffer');
BufferStreamHandler::stream_register();
}
}

Expand Down
31 changes: 29 additions & 2 deletions libraries/src/Utility/BufferStreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

defined('JPATH_PLATFORM') or die;

// Register the stream
stream_wrapper_register('buffer', '\\Joomla\\CMS\\Utility\\BufferStreamHandler');
// Workaround for B/C. Will be removed with 4.0
BufferStreamHandler::stream_register();

/**
* Generic Buffer stream handler
Expand Down Expand Up @@ -47,6 +47,33 @@ class BufferStreamHandler
*/
public $buffers = array();

/**
* Status of registering the wrapper
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
static private $registered = false;

/**
* Function to register the stream wrapper
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public static function stream_register()
{
if (!self::$registered)
{
stream_wrapper_register('buffer', '\\Joomla\\CMS\\Utility\\BufferStreamHandler');

self::$registered = true;
}

return;
}

/**
* Function to open file or url
*
Expand Down