Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Alternative GridFS collection names issue fix.[dev] #766

Merged
merged 1 commit into from

2 participants

@3d0c

There is a problem in source/MongoDb.php, it doesn't work with GridFS collections which is named different to defaults.

This call doesn't pass prefix to the getGridFS and defaults "fs.files" will be used, here it is:

$collection = $self->connection->getGridFS();

This PR has a fix for this issue.

But there is one more problem — unable to use different sources for gridfs collection, because of this:

if ($source == "{$_config['gridPrefix']}.files")

I'm afraid It's a wrong way to determine the type of collection — is it gridfs or not.

I'm working now on the solution.

@nateabele
Owner

Hi, thanks for the patch. Can you show me a test that demonstrates the issue? Also, it looks as though your editor added an extra newline at the end of the patch.

@3d0c 3d0c referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@3d0c 3d0c referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@3d0c 3d0c referenced this pull request from a commit in 3d0c/lithium
@3d0c 3d0c Fixes for issue #766 0524db2
@nateabele
Owner

Since we're working out the details of the test, I'm just gonna go ahead and merge this. Please do me a favor and clean up the trailing newline in the test PR though. :-) Thanks!

@nateabele nateabele merged commit 215faf8 into UnionOfRAD:dev

1 check passed

Details default The Travis build passed
@jails jails referenced this pull request from a commit
@jails jails Fix #766. 17a187d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 23, 2012
  1. @3d0c
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 data/source/MongoDb.php
View
8 data/source/MongoDb.php
@@ -396,7 +396,7 @@ public function create($query, array $options = array()) {
protected function _saveFile($data) {
$uploadKeys = array('name', 'type', 'tmp_name', 'error', 'size');
- $grid = $this->connection->getGridFS();
+ $grid = $this->connection->getGridFS($this->_config['gridPrefix']);
$file = null;
$method = null;
@@ -456,7 +456,7 @@ public function read($query, array $options = array()) {
$collection = $self->connection->{$source};
if ($source == "{$_config['gridPrefix']}.files") {
- $collection = $self->connection->getGridFS();
+ $collection = $self->connection->getGridFS($_config['gridPrefix']);
}
$result = $collection->find($args['conditions'], $args['fields']);
@@ -563,7 +563,7 @@ public function delete($query, array $options = array()) {
protected function _deleteFile($conditions, $options = array()) {
$defaults = array('safe' => true);
$options += $defaults;
- return $this->connection->getGridFS()->remove($conditions, $options);
+ return $this->connection->getGridFS($this->_config['gridPrefix'])->remove($conditions, $options);
}
/**
@@ -809,4 +809,4 @@ protected function _checkConnection() {
}
}
-?>
+?>
Something went wrong with that request. Please try again.