diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 1d85e5fad..fc0703fd9 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -262,8 +262,7 @@ class PostUpdate $item['owner-id'] = Contact::getIdForURL($item["owner-link"], 0, false, $default); } - if (!is_null($item['allow_cid']) && !is_null($item['allow_gid']) - && !is_null($item['deny_cid']) && !is_null($item['deny_gid'])) { + if (empty($item['psid'])) { $item['psid'] = PermissionSet::fetchIDForPost($item); } else { $item['allow_cid'] = null; diff --git a/src/Model/Item.php b/src/Model/Item.php index 77d63ca50..bc883aa3c 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -16,6 +16,7 @@ use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Model\Contact; +use Friendica\Model\PermissionSet; use Friendica\Object\Image; use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; diff --git a/src/Model/PermissionSet.php b/src/Model/PermissionSet.php index f83f9ccb5..cbbde2ae0 100644 --- a/src/Model/PermissionSet.php +++ b/src/Model/PermissionSet.php @@ -22,11 +22,6 @@ class PermissionSet extends BaseObject */ public static function fetchIDForPost(&$postarray) { - if (is_null($postarray['allow_cid']) || is_null($postarray['allow_gid']) - || is_null($postarray['deny_cid']) || is_null($postarray['deny_gid'])) { - return null; - } - $condition = ['uid' => $postarray['uid'], 'allow_cid' => self::sortPermissions(defaults($postarray, 'allow_cid', '')), 'allow_gid' => self::sortPermissions(defaults($postarray, 'allow_gid', '')), diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index efb2cb03d..e7aa572dd 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -43,6 +43,11 @@ class Expire if (!empty($row['psid']) && !DBA::exists('item', ['psid' => $row['psid']])) { DBA::delete('permissionset', ['id' => $row['psid']]); } + // When the permission set will be used in photo and events as well. + // this query here needs to be extended. + if (!empty($row['psid']) && !dba::exists('item', ['psid' => $row['psid']])) { + dba::delete('permissionset', ['id' => $row['psid']]); + } } DBA::close($rows); diff --git a/update.php b/update.php index 812f81faf..257623ac7 100644 --- a/update.php +++ b/update.php @@ -258,3 +258,15 @@ function update_1278() { return UPDATE_SUCCESS; } + +function update_1278() { + Config::set('system', 'maintenance', 1); + Config::set('system', 'maintenance_reason', L10n::t('%s: Updating post-type.', DBM::date().' '.date('e'))); + + Item::update(['post-type' => Item::PT_PAGE], ['bookmark' => true]); + Item::update(['post-type' => Item::PT_PERSONAL_NOTE], ['type' => 'note']); + + Config::set('system', 'maintenance', 0); + + return UPDATE_SUCCESS; +}