Author: kn
Date: Tue Oct 2 13:43:17 2007
New Revision: 6330
Log:
- Prevent from setting live properties
Modified:
trunk/Webdav/src/backends/file.php
trunk/Webdav/tests/backend_file_test.php
Modified: trunk/Webdav/src/backends/file.php
==============================================================================
--- trunk/Webdav/src/backends/file.php [iso-8859-1] (original)
+++ trunk/Webdav/src/backends/file.php [iso-8859-1] Tue Oct 2 13:43:17 2007
@@ -42,6 +42,22 @@
protected $root;
/**
+ * Names of live properties from the DAV: namespace which will be handled
+ * live, and should not bestored like dead properties.
+ *
+ * @var array
+ */
+ protected $handledLiveProperties = array(
+ 'getcontentlength',
+ 'getlastmodified',
+ 'creationdate',
+ 'displayname',
+ 'getcontenttype',
+ 'getetag',
+ 'resourcetype'
+ );
+
+ /**
* Construct backend from a given path.
*
* @param string $path
@@ -336,9 +352,13 @@
{
$storage = $this->getPropertyStoragePath( $resource, $property );
- // @TODO: We should handle some (/most?) of the live properties
- // differently.
- //
+ // Check if property is a self handled live property and return an
+ // error in this case.
+ if ( in_array( $property->name, $this->handledLiveProperties, true ) )
+ {
+ return false;
+ }
+
// @TODO: Get rid of serialize here. We should either store them as
// vlaid XML, or use var_export. Both make some internal serialize
// methods fpr all properties necessary.
@@ -489,8 +509,7 @@
}
// Also attach generated live properties
- $liveProperties = array( 'getcontentlength', 'getlastmodified',
'creationdate', 'displayname', 'getcontenttype', 'getetag', 'resourcetype' );
- foreach( $liveProperties as $name )
+ foreach( $this->handledLiveProperties as $name )
{
$storage->attach( $this->getProperty( $resource, $name ) );
}
Modified: trunk/Webdav/tests/backend_file_test.php
==============================================================================
--- trunk/Webdav/tests/backend_file_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/backend_file_test.php [iso-8859-1] Tue Oct 2 13:43:17
2007
@@ -1360,6 +1360,48 @@
$expectedResponse,
$response,
'Expected response does not match real response.',
+ 0,
+ 20
+ );
+ }
+
+ public function testPropPatchSetLiveProperty()
+ {
+ $backend = new ezcWebdavFileBackend( $this->tempDir . 'backend/' );
+
+ $newProperties = new ezcWebdavFlaggedPropertyStorage();
+ $newProperties->attach(
+ $p = new ezcWebdavGetContentLengthProperty( '23' ),
+ ezcWebdavPropPatchRequest::SET
+ );
+
+ $request = new ezcWebdavPropPatchRequest( '/resource' );
+ $request->updates = $newProperties;
+ $request->validateHeaders();
+ $response = $backend->proppatch( $request );
+
+ $failed = new ezcWebdavBasicPropertyStorage();
+ $failed->attach( $p );
+ $failed->rewind();
+
+ $this->assertEquals(
+ new ezcWebdavPropPatchResponse(
+ new ezcWebdavResource( '/resource' ),
+ new ezcWebdavPropStatResponse(
+ $failed,
+ ezcWebdavResponse::STATUS_403
+ ),
+ new ezcWebdavPropStatResponse(
+ new ezcWebdavBasicPropertyStorage(),
+ ezcWebdavResponse::STATUS_409
+ ),
+ new ezcWebdavPropStatResponse(
+ new ezcWebdavBasicPropertyStorage(),
+ ezcWebdavResponse::STATUS_424
+ )
+ ),
+ $response,
+ 'Expected property removing PROPPATCH response does not match real
response.',
0,
20
);
--
svn-components mailing list
[EMAIL PROTECTED]
http://lists.ez.no/mailman/listinfo/svn-components