fix broken properties in the database
This commit is contained in:
parent
c0e37c7d69
commit
bd63fddbf4
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// fix webdav properties, remove namespace information between curly bracket
|
// fix webdav properties, remove namespace information between curly bracket (update from OC4 to OC5)
|
||||||
$installedVersion=OCP\Config::getAppValue('files', 'installed_version');
|
$installedVersion=OCP\Config::getAppValue('files', 'installed_version');
|
||||||
if (version_compare($installedVersion, '1.1.4', '<')) {
|
if (version_compare($installedVersion, '1.1.4', '<')) {
|
||||||
$query = OC_DB::prepare( "SELECT propertyname, propertypath, userid FROM `*PREFIX*properties`" );
|
$query = OC_DB::prepare( "SELECT propertyname, propertypath, userid FROM `*PREFIX*properties`" );
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
while( $row = $result->fetchRow()){
|
while( $row = $result->fetchRow()){
|
||||||
$query = OC_DB::prepare( 'UPDATE *PREFIX*properties SET propertyname = ? WHERE userid = ? AND propertypath = ?' );
|
$query = OC_DB::prepare( 'UPDATE *PREFIX*properties SET propertyname = ? WHERE userid = ? AND propertypath = ?' );
|
||||||
$query->execute( array( preg_replace("/{.*}/", "", $row["propertyname"]),$row["userid"], $row["propertypath"] ));
|
$query->execute( array( preg_replace("/^{.*}/", "", $row["propertyname"]),$row["userid"], $row["propertypath"] ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
|
||||||
public function updateProperties($properties) {
|
public function updateProperties($properties) {
|
||||||
$existing = $this->getProperties(array());
|
$existing = $this->getProperties(array());
|
||||||
foreach($properties as $propertyName => $propertyValue) {
|
foreach($properties as $propertyName => $propertyValue) {
|
||||||
$propertyName = preg_replace("/^{.*}/", "", $propertyName); // fix broken property name
|
$propertyName = preg_replace("/^{.*}/", "", $propertyName); // remove leading namespace from property name
|
||||||
// If it was null, we need to delete the property
|
// If it was null, we need to delete the property
|
||||||
if (is_null($propertyValue)) {
|
if (is_null($propertyValue)) {
|
||||||
if(array_key_exists( $propertyName, $existing )){
|
if(array_key_exists( $propertyName, $existing )){
|
||||||
|
|
Loading…
Reference in New Issue