Page MenuHomeIn-Portal Phabricator

D49.id.diff
No OneTemporary

File Metadata

Created
Fri, Jun 13, 5:24 PM

D49.id.diff

Index: branches/5.2.x/core/units/helpers/priority_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/priority_helper.php
+++ branches/5.2.x/core/units/helpers/priority_helper.php
@@ -51,7 +51,7 @@
$items_count = $this->Conn->GetOne($sql);
$current_priority = $object instanceof kDBList ? 0 : $object->GetDBField('Priority');
- if ( $is_new || $current_priority == -($items_count + 1) ) {
+ if ( $is_new || $current_priority == -($items_count + 1) || $this->isTempTableOnly($object) ) {
$items_count++;
}
@@ -73,6 +73,22 @@
}
/**
+ * Determines if an item only exists in temp table.
+ *
+ * @param kDBBase $object Object.
+ *
+ * @return boolean
+ */
+ protected function isTempTableOnly(kDBBase $object)
+ {
+ if ( !$object->IsTempTable() || ($object instanceof kDBList) ) {
+ return false;
+ }
+
+ return $object->GetID() <= 0;
+ }
+
+ /**
* Updates priorities for changed items
*
* @param kEvent $event

Event Timeline