Skip to content

Commit

Permalink
Merge branch '9.4/bugfixes' into 9.5/bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed May 15, 2019
2 parents cfe3501 + 0bfe74a commit 991b3cd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
18 changes: 9 additions & 9 deletions inc/commonitilobject.class.php
Expand Up @@ -6309,7 +6309,7 @@ function getTimelineItems() {
$restrict_fup['itemtype'] = self::getType();
$restrict_fup['items_id'] = $this->getID();

if (!Session::haveRight("task", CommonITILTask::SEEPRIVATE)) {
if ($task_obj->maybePrivate() && !Session::haveRight("task", CommonITILTask::SEEPRIVATE)) {
$restrict_task = [
'OR' => [
'is_private' => 0,
Expand Down Expand Up @@ -6596,9 +6596,9 @@ function showTimeline($rand) {
echo "<span class='cancel_edit_item_content'></span>";
}
echo "<div class='displayed_content'>";
echo "<div class='h_controls'>";
if (!in_array($item['type'], ['Document_Item', 'Assign'])
&& $item_i['can_edit']) {
echo "<div class='h_controls'>";
// merge/split icon
if ($objType == 'Ticket' && $item['type'] == ITILFollowup::getType()) {
if (isset($item_i['sourceof_items_id']) && $item_i['sourceof_items_id'] > 0) {
Expand All @@ -6617,15 +6617,15 @@ function showTimeline($rand) {
echo "<span class='far fa-edit control_item' title='".__('Edit')."'";
echo "onclick='javascript:viewEditSubitem".$this->fields['id']."$rand(event, \"".$item['type']."\", ".$item_i['id'].", this, \"$randdomid\")'";
echo "></span>";
}

// show "is_private" icon
if (isset($item_i['is_private']) && $item_i['is_private']) {
echo "<span class='private'><i class='fas fa-lock control_item' title='" . __s('Private') .
"'></i><span class='sr-only'>".__('Private')."</span></span>";
}

echo "</div>";
// show "is_private" icon
if (isset($item_i['is_private']) && $item_i['is_private']) {
echo "<span class='private'><i class='fas fa-lock control_item' title='" . __s('Private') .
"'></i><span class='sr-only'>".__('Private')."</span></span>";
}

echo "</div>";
if (isset($item_i['requesttypes_id'])
&& file_exists("$pics_url/".$item_i['requesttypes_id'].".png")) {
echo "<img src='$pics_url/".$item_i['requesttypes_id'].".png' class='h_requesttype' />";
Expand Down
2 changes: 1 addition & 1 deletion inc/commonitiltask.class.php
Expand Up @@ -653,7 +653,7 @@ static function rawSearchOptionsToAdd($itemtype = null) {
$name = _n('Task', 'Tasks', Session::getPluralNumber());

$task_condition = '';
if (!Session::haveRight("task", CommonITILTask::SEEPRIVATE)) {
if ($task->maybePrivate() && !Session::haveRight("task", CommonITILTask::SEEPRIVATE)) {
$task_condition = "AND (`NEWTABLE`.`is_private` = 0
OR `NEWTABLE`.`users_id` = '".Session::getLoginUserID()."')";
}
Expand Down
18 changes: 12 additions & 6 deletions inc/commontreedropdown.class.php
Expand Up @@ -188,9 +188,7 @@ function prepareInputForUpdate($input) {
$input["ancestors_cache"] = '';
if (Toolbox::useCache()) {
$ckey = $this->getTable() . '_ancestors_cache_' . $this->getID();
if ($GLPI_CACHE->has($ckey)) {
$GLPI_CACHE->delete($ckey);
}
$GLPI_CACHE->delete($ckey);
}
return $this->adaptTreeFieldsFromUpdateOrAdd($input);
}
Expand All @@ -215,9 +213,7 @@ function regenerateTreeUnderID($ID, $updateName, $changeParent) {
//drop from sons cache when needed
if ($changeParent && Toolbox::useCache()) {
$ckey = $this->getTable() . '_ancestors_cache_' . $ID;
if ($GLPI_CACHE->has($ckey)) {
$GLPI_CACHE->delete($ckey);
}
$GLPI_CACHE->delete($ckey);
}

if (($updateName) || ($changeParent)) {
Expand Down Expand Up @@ -316,6 +312,11 @@ protected function cleanParentsSons($id = null, $cache = true) {
unset($sons[$this->getID()]);
$GLPI_CACHE->set($ckey, $sons);
}
} else {
// If cache key does not exists in current context (UI using APCu), it may exists
// in another context (CLI using filesystem). So we force deletion of cache in all contexts
// to be sure to not use a stale value.
$GLPI_CACHE->delete($ckey);
}
}
}
Expand All @@ -341,6 +342,11 @@ protected function addSonInParents() {
$sons[$this->getID()] = (string)$this->getID();
$GLPI_CACHE->set($ckey, $sons);
}
} else {
// If cache key does not exists in current context (UI using APCu), it may exists
// in another context (CLI using filesystem). So we force deletion of cache in all contexts
// to be sure to not use a stale value.
$GLPI_CACHE->delete($ckey);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions inc/entity.class.php
Expand Up @@ -132,9 +132,7 @@ function pre_deleteItem() {
$this->cleanParentsSons();
if (Toolbox::useCache()) {
$ckey = $this->getTable() . '_ancestors_cache_' . $this->getID();
if ($GLPI_CACHE->has($ckey)) {
$GLPI_CACHE->delete($ckey);
}
$GLPI_CACHE->delete($ckey);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion inc/session.class.php
Expand Up @@ -311,7 +311,7 @@ static function changeActiveEntities($ID = "all", $is_recursive = false) {
$newentities = [];
$newroots = [];
if (isset($_SESSION['glpiactiveprofile'])) {
if ($ID == "all") {
if ($ID === "all") {
$ancestors = [];
foreach ($_SESSION['glpiactiveprofile']['entities'] as $key => $val) {
$ancestors = array_unique(array_merge(getAncestorsOf("glpi_entities",
Expand Down

0 comments on commit 991b3cd

Please sign in to comment.