Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/2.3.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Dec 10, 2013
2 parents 156acfb + a810324 commit 28872a9
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 50 deletions.
25 changes: 22 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@ language: php

php:
- 5.4
- 5.5

env:
- GENGHIS_BACKEND=ruby
- GENGHIS_BACKEND=php
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.1.4
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.2.12
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.3.0
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.3.4
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.3.7
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.4.0
- GENGHIS_BACKEND=php MONGO_PHP_VERSION=1.4.3

matrix:
exclude:
- php: 5.5
env: GENGHIS_BACKEND=ruby

services: mongodb

before_script:
- 'echo "extension=mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini'
- 'bundle install --without development'
- 'sh -c "if [ ! -z $MONGO_PHP_VERSION ]; then pecl install -f mongo-${MONGO_PHP_VERSION}; fi"'
- 'sh -c "if [ -z $(php -i | grep mongo) ]; then echo extension=mongo.so >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"'

install: bundle install --without development

# wheee!
script: rspec
script: rspec
8 changes: 8 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v2.3.9

* [Fix #135][i135] — error when entering a `new Date()` value in a document.
* Fix (future) backwards compatibility breaks in the PHP Mongo driver (using `'safe' => true` with `MongoClient`).

[i135]: https://github.com/bobthecow/genghis/issues/135


## v2.3.8

* [Fix #130][i130] — Resolve bug creating or editing `ISODate` instances with years between 1 and 99.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.8
2.3.9
36 changes: 18 additions & 18 deletions genghis.php

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions genghis.rb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions genghisapp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
gem.add_dependency 'vegas', '~> 0.1.8'
gem.add_dependency 'sinatra', '>= 1.3.3', '< 1.5.0'
gem.add_dependency 'sinatra-contrib', '>= 1.3.1', '< 1.5.0'
gem.add_dependency 'sinatra-mustache', '>= 0.0.4', '< 0.2.0'
gem.add_dependency 'mongo', '>= 1.8.0', '<= 1.9.0'
gem.add_dependency 'sinatra-mustache', '>= 0.0.4', '< 0.4.0'
gem.add_dependency 'mongo', '>= 1.8.0', '<= 1.9.2'
gem.add_dependency 'json', '>= 1.7.0', '< 1.9.0'

gem.add_development_dependency 'rake'
Expand Down
11 changes: 7 additions & 4 deletions spec/requests/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,19 @@

describe 'GET /servers/:server/databases/:db/collections/:coll' do
before :all do
@db.create_collection 'foo bar.baz/qux\\quux…'
# TODO: fix path chunks with encoded slashes in them
# so this test can work under rack-protect v1.5.1+
# @db.create_collection 'foo bar.baz/qux\\quux…'
@db.create_collection 'foo bar.baz:qux\\quux…'
end

it 'returns collection info' do
res = @api.get '/servers/localhost/databases/__genghis_spec_test__/collections/foo%20bar.baz%2Fqux%5Cquux%E2%80%A6'
res = @api.get '/servers/localhost/databases/__genghis_spec_test__/collections/foo%20bar.baz:qux%5Cquux%E2%80%A6'

res.status.should eq 200
res.body.should match_json_expression \
id: 'foo bar.baz/qux\\quux…',
name: 'foo bar.baz/qux\\quux…',
id: 'foo bar.baz:qux\\quux…',
name: 'foo bar.baz:qux\\quux…',
count: 0,
indexes: Array,
stats: Hash
Expand Down
21 changes: 18 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

RSpec.configure do |config|
def genghis_backends
[:php, :ruby]
if ENV['GENGHIS_BACKEND']
ENV['GENGHIS_BACKEND'].split(',').map(&:to_sym)
else
[:php, :ruby]
end
end

def find_available_port
Expand All @@ -21,15 +25,26 @@ def start_backend(backend)
case backend
when :php
@genghis_pid = spawn 'php', '-S', "localhost:#{@genghis_port}", 'genghis.php', :out => '/dev/null'
sleep 0.2
Faraday.new url: "http://localhost:#{@genghis_port}"
api = Faraday.new url: "http://localhost:#{@genghis_port}"
0.upto(20) do |i|
break if api_started?(api)
sleep 0.1
end
api
when :ruby
Faraday.new do |conn|
conn.adapter :rack, Genghis::Server.new
end
end
end

def api_started?(api)
api.get '/'
true
rescue Faraday::Error::ConnectionFailed => e
false
end

def encode_upload(file)
"data:text/plain;base64," + Base64.strict_encode64(file)
end
Expand Down
4 changes: 4 additions & 0 deletions src/js/genghis/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Genghis.JSON = {
};
}

function GenghisDate(date) {
return new ISODate(date);
}

function ISODate(date) {
function ISODateString(d) {
function pad(n, l) {
Expand Down
17 changes: 13 additions & 4 deletions src/php/Genghis/Models/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function offsetSet($id, $doc)
$query = array('_id' => $this->thunkMongoId($id));

try {
$result = $this->collection->update($query, $doc, array('safe' => true));
$result = $this->collection->update($query, $doc, self::safe());
} catch (MongoCursorException $e) {
throw new Genghis_HttpException(400, ucfirst($e->doc['err']));
}
Expand All @@ -53,8 +53,8 @@ public function offsetUnset($id)
{
$this->findDocument($id);

$query = array('_id' => $this->thunkMongoId($id));
$result = $this->collection->remove($query, array('safe' => true));
$query = array('_id' => $this->thunkMongoId($id));
$result = $this->collection->remove($query, self::safe());

if (!(isset($result['ok']) && $result['ok'])) {
throw new Genghis_HttpException;
Expand Down Expand Up @@ -164,7 +164,7 @@ public function findDocuments($query = null, $page = 1)
public function insert($data)
{
try {
$result = $this->collection->insert($data, array('safe' => true));
$result = $this->collection->insert($data, self::safe());
} catch (MongoCursorException $e) {
throw new Genghis_HttpException(400, ucfirst($e->doc['err']));
}
Expand Down Expand Up @@ -258,4 +258,13 @@ private function stats()
{
return $this->database->database->command(array('collStats' => $this->collection->getName()));
}

private static function safe()
{
if (version_compare(Mongo::VERSION, '1.3.0', '>=')) {
return array('w' => 1);
} else {
return array('safe' => true);
}
}
}

0 comments on commit 28872a9

Please sign in to comment.