Author: rick
Date: 2010-03-16 12:23:02 +0100 (Tue, 16 Mar 2010)
New Revision: 28548
Modified:
plugins/sfCouchPlugin/trunk/lib/sfCouchConnection.class.php
plugins/sfCouchPlugin/trunk/lib/sfCouchDocument.class.php
plugins/sfCouchPlugin/trunk/lib/sfCouchResponse.class.php
plugins/sfCouchPlugin/trunk/lib/sfCouchView.class.php
Log:
cleanup
Modified: plugins/sfCouchPlugin/trunk/lib/sfCouchConnection.class.php
===================================================================
--- plugins/sfCouchPlugin/trunk/lib/sfCouchConnection.class.php 2010-03-16
09:59:38 UTC (rev 28547)
+++ plugins/sfCouchPlugin/trunk/lib/sfCouchConnection.class.php 2010-03-16
11:23:02 UTC (rev 28548)
@@ -364,9 +364,12 @@
return null;
break;
}
+
+ if ($headers['content-type'] == 'application/octet-stream') {
+ return ($body);
+ }
// Create repsonse object from couch db response
return sfCouchResponse::parse( $headers, $body);
}
-}
-
+}
\ No newline at end of file
Modified: plugins/sfCouchPlugin/trunk/lib/sfCouchDocument.class.php
===================================================================
--- plugins/sfCouchPlugin/trunk/lib/sfCouchDocument.class.php 2010-03-16
09:59:38 UTC (rev 28547)
+++ plugins/sfCouchPlugin/trunk/lib/sfCouchDocument.class.php 2010-03-16
11:23:02 UTC (rev 28548)
@@ -345,8 +345,6 @@
json_encode( $this->storage )
);
}
-
- print_r($response);
if (empty($response)) {
return null;
@@ -416,13 +414,13 @@
* Get the contents of an attached file as a sfCouchDataResponse.
*
* @param string $fileName
- * @return sfCouchDataResponse
+ * @return String tempFileName
*/
public function getFile( $fileName )
{
if ( !isset( $this->storage->_attachments[$fileName] ) )
{
- throw new sfException( $fileName );
+ return null;
}
$db = sfCouchConnection::getInstance();
@@ -431,6 +429,13 @@
null, true
);
- return $response;
+ if (is_null($response)) {
+ return null;
+ }
+
+ $fileName = tempnam(sys_get_temp_dir(), 'sfCouch_');
+ file_put_contents($fileName, $response);
+
+ return $fileName;
}
}
\ No newline at end of file
Modified: plugins/sfCouchPlugin/trunk/lib/sfCouchResponse.class.php
===================================================================
--- plugins/sfCouchPlugin/trunk/lib/sfCouchResponse.class.php 2010-03-16
09:59:38 UTC (rev 28547)
+++ plugins/sfCouchPlugin/trunk/lib/sfCouchResponse.class.php 2010-03-16
11:23:02 UTC (rev 28548)
@@ -149,6 +149,4 @@
throw new sfException( $headers['status'] );
}
}
-}
-
-
+}
\ No newline at end of file
Modified: plugins/sfCouchPlugin/trunk/lib/sfCouchView.class.php
===================================================================
--- plugins/sfCouchPlugin/trunk/lib/sfCouchView.class.php 2010-03-16
09:59:38 UTC (rev 28547)
+++ plugins/sfCouchPlugin/trunk/lib/sfCouchView.class.php 2010-03-16
11:23:02 UTC (rev 28548)
@@ -1,6 +1,6 @@
<?php
/**
- * Wrapper base for views in the database
+ * Wrapper for views in the database
*
* @package Core
* @version $Revision: 94 $
@@ -23,7 +23,7 @@
* @param array $options
* @return string
*/
- private static function buildViewQuery( array $options )
+ private static function buildViewQuery(array $options)
{
// Return empty query string, if no options has been passed
if ( $options === array() )
@@ -112,7 +112,7 @@
// Always refresh the configuration in debug mode
if(sfConfig::get('sf_debug')) {
- self::refreshDesignDoc();
+ self::checkDesignDoc($view);
}
try
@@ -126,7 +126,7 @@
// If we aren't in debug mode Ensure view has been created
properly and then try to execute
// the query again. If it still fails, there is most probably a
// real problem.
- if (!sfConfig::get('sf_debug') && self::refreshDesignDoc()) {
+ if (!sfConfig::get('sf_debug') && self::checkDesignDoc($view)) {
$response = $db->get($url);
}
}
@@ -144,7 +144,7 @@
*
* @return void
*/
- public static function refreshDesignDoc()
+ public static function checkDesignDoc($checkView = null)
{
$designDoc = new sfCouchDocument(self::viewName);
@@ -155,6 +155,15 @@
$designDoc->views = self::getViewsFromConfig($mapDir);
$designDoc->save();
+
+ if ($checkView) {
+ if (!array_key_exists($checkView, $designDoc->views)) {
+ throw new sfException("The view '$checkView' doesn't exist.
+ Create it in /config/couchdb/".$checkView."_map.js");
+ }
+ }
+
+ return true;
}
private static function getViewsFromConfig($dir)
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.