Bug #34555

StreamWrapperAdapter::stream_lock does not return StreamWrapper result

Added by Bastian Waidelich almost 9 years ago. Updated almost 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
Resource
Start date:
2012-03-06
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

While writing unit tests for the StreamWrapperAdapter, I came upon this issue: StreamWrapperAdapter::stream_lock() does not return the results of the actual stream wrapper. But according to the docs this "returns TRUE on success or FALSE on failure.".

Apart from that the StreamWrapperAdapter is lacking unit tests currently

Most of the functions in StreamWrapperAdapter call createStreamWrapper() in order to retrieve the actual StreamWrapper. The method looks like this:

protected function createStreamWrapper($path) {
    if ($this->streamWrapper === NULL) {
        $explodedPath = explode(':', $path, 2);
        $scheme = array_shift($explodedPath);
        $this->streamWrapper = self::$objectManager->create(self::$registeredStreamWrappers[$scheme]);
    }
}

If I get it right, this means that the streamWrapper is only instantiated the first time this method is called. createStreamWrapper('sheme1://foo'); createStreamWrapper('sheme2://bar'); would return the same instance.

NOTE: As Karsten mentioned in the comments, this is probably not true as PHP will create a fresh instance of the adapter for every use. But this should be secured with tests (also to prevent issues like #34547)


Related issues

Related to TYPO3.Flow - Bug #34547: wrong variable name inside rename() of StreamWrapperAdapterResolvedBernhard Fischer2012-03-06

Actions
#1

Updated by Karsten Dambekalns almost 9 years ago

Bastian Waidelich wrote:

If I get it right, this means that the streamWrapper is only instantiated the first time this method is called. createStreamWrapper('sheme1://foo'); createStreamWrapper('sheme2://bar'); would return the same instance.

Yes, but for every use of a stream wrapper, PHP creates a fresh instance. Thus this is not an issue AFAICS.

#2

Updated by Bastian Waidelich almost 9 years ago

  • Tracker changed from Bug to Task
  • Subject changed from StreamWrapperAdapter only works for one scheme to Add tests for StreamWrapperAdapter

Karsten Dambekalns wrote:

If I get it right, this means that the streamWrapper is only instantiated the first time [...]

Yes, but for every use of a stream wrapper, PHP creates a fresh instance.
Thus this is not an issue AFAICS.

Ok, this makes sense of course - but we should secure this with some tests IMO. I adjusted the subject accordingly.

#3

Updated by Bastian Waidelich almost 9 years ago

  • Status changed from New to Accepted
  • Assignee set to Bastian Waidelich
  • Target version set to 1.1
#4

Updated by Bastian Waidelich almost 9 years ago

  • Tracker changed from Task to Bug
  • Subject changed from Add tests for StreamWrapperAdapter to StreamWrapperAdapter::stream_lock does not return StreamWrapper result
#5

Updated by Gerrit Code Review almost 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9788

#6

Updated by Gerrit Code Review almost 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9788

#7

Updated by Bastian Waidelich almost 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF