Выполняется в транзакции

@param bool $newValue
@return bool
16038
public function isTransaction($newValue = null)
    {
        if (null !== $newValue) {
            $this->isTransaction = (bool) $newValue;
        }
        return $this->isTransaction;
    }
830224
public function addNode( $nodeName, $nodeValue = false )
	{
		$newNode = new ADT_Graph_Node( $nodeName, $nodeValue );
		if( !$this->isNode( $newNode ) )
		{
			$this->nodes[] = $newNode;
			return $newNode;
		}
		else
			return $this->getNode( $nodeName );
	}
1211916
public static function update($cohortid, $newvalue) {
        global $DB;
        $cohort = $DB->get_record('cohort', array('id' => $cohortid), '*', MUST_EXIST);
        $cohortcontext = \context::instance_by_id($cohort->contextid);
        \external_api::validate_context($cohortcontext);
        require_capability('moodle/cohort:manage', $cohortcontext);
        $record = (object)array('id' => $cohort->id, 'idnumber' => $newvalue, 'contextid' => $cohort->contextid);
        cohort_update_cohort($record);
        $cohort->idnumber = $newvalue;
        return new static($cohort);
    }
124435
public function notSame($anotherValue)
    {
        if (is_object($anotherValue)) {
            throw new InvalidNotObjectException('anotherValue');
        }

        if ($this->value === $anotherValue) {
            throw new InvalidNotSameValueException($this->name, $this->value);
        }

        return $this;
    }
1088060
public static function write($config, array $newValues = [], $validate = true)
    {
        $config = new Repository($config);

        foreach ($newValues as $key => $value) {
            $config->set($key, $value);
        }

        $config->save(null, null, $validate);
    }
27722
public function isValidItem($mixValue){
		if(is_object($mixValue)){
			if($this->hasOption('max')){
				if(count($this->mixValue)>=$this->options()->max){
					throw new MaxException($this->options()->max);
					return false;
				}
			}

			if($this->hasOption('class')){
				$strClass = $this->options()->class;
				if(!$mixValue instanceof $strClass){
					throw new ClassException($mixValue, $this->options()->class);
					return false;
				}
			}
			return true;
		}
		return false;
	}
1018219
protected function updateHumanity($newValue)
    {
        if ($newValue > 0) {
            $this->session->set($this->key . '_humanity', $newValue);
        } else {
            $this->session->remove($this->key . '_humanity');
        }

        return null;
    }
1173308
public boolean getAndSet(boolean newValue) {
        boolean oldValue = value.getAndSet(newValue);
        // did the state change?
        if (oldValue != newValue)
            valueTime = System.currentTimeMillis();
        return oldValue;
    }
1075216
public function set($newvalues)
    {
        $array = $this->toArray();
        foreach ($newvalues as $key => $value) {
            $this->$key = $value;
        }
        return $this;
    }
1164008
private function onPropertyChanged($name, $oldValue, $newValue)
    {
        foreach ($this->listeners as $listener) {
            $listener->propertyChanged($this, $name, $oldValue, $newValue);
        }
    }
404761
public function updateValue($group, $variableCode, $newValue)
    {
        $variable = clone $this->getVariable($variableCode);
        $variable->setValue($newValue);

        if (!isset($this->queuedForUpdate[$group->getName()])) {
            $this->queuedForUpdate[$group->getName()]['time'] = microtime(true);
        }

        $checkVariable = clone $this->checkVariable;
        $uniqueId = uniqid('exp_', true);
        $checkVariable->setValue("\"$uniqueId\"");

        $this->checkWindow->setValue(Builder::escapeText(get_called_class()));
        $this->queuedForUpdate[$group->getName()]['group'] = $group;
        $this->queuedForUpdate[$group->getName()]['variables'][$variableCode] = $variable;
        $this->queuedForUpdate[$group->getName()]['check'] = $checkVariable;
    }
32823
public function getNewValue(int $maxValue, int $changeValue, string $progressType)
    {
        switch ($progressType) {
            case AchievementCriteriaChange::PROGRESS_SET:
                $newValue = $changeValue;
                break;
            case AchievementCriteriaChange::PROGRESS_ACCUMULATE:
                $newValue = $this->value + $changeValue;

                if ($maxValue > 0) {
                    $newValue = $maxValue - $this->value > $changeValue ? $this->value + $changeValue : $maxValue;
                }
                break;
            case AchievementCriteriaChange::PROGRESS_HIGHEST:
                $newValue = $this->value < $changeValue ? $changeValue : $this->value;
                break;
            default:
                throw new \InvalidArgumentException('Given progress type is invalid ('.$progressType.').');
        }

        return $newValue;
    }
114816
private function valuesAreEqual( $firstValue, $secondValue ): bool {
		if ( $this->comparer === null ) {
			$this->comparer = new StrictComparer();
		}

		return $this->comparer->valuesAreEqual( $firstValue, $secondValue );
	}
432419
public static function update($itemid, $newvalue) {
        global $DB, $CFG;

        require_once($CFG->libdir . '/external/externallib.php');
        // Check caps.
        // Do the thing.
        // Return one of me.
        // Validate the inputs.
        list($courseid, $userid) = explode(':', $itemid, 2);

        $courseid = clean_param($courseid, PARAM_INT);
        $userid = clean_param($userid, PARAM_INT);
        $roleids = json_decode($newvalue);
        foreach ($roleids as $index => $roleid) {
            $roleids[$index] = clean_param($roleid, PARAM_INT);
        }

        // Check user is enrolled in the course.
        $context = context_course::instance($courseid);
        core_external::validate_context($context);

        // Check permissions.
        require_capability('moodle/role:assign', $context);

        if (!is_enrolled($context, $userid)) {
            throw new coding_exception('User does not belong to the course');
        }

        // Check that all the groups belong to the course.
        $allroles = role_fix_names(get_all_roles($context), $context);
        $assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false);
        $viewableroles = get_viewable_roles($context);
        $userrolesbyid = get_user_roles($context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
        $profileroles = get_profile_roles($context);

        // Set an array where the index is the roleid.
        $userroles = array();
        foreach ($userrolesbyid as $id => $role) {
            $userroles[$role->roleid] = $role;
        }

        $rolestoprocess = [];
        foreach ($roleids as $roleid) {
            if (!isset($assignableroles[$roleid])) {
                throw new coding_exception('Role cannot be assigned in this course.');
            }
            $rolestoprocess[$roleid] = $roleid;
        }

        // Process adds.
        foreach ($rolestoprocess as $roleid) {
            if (!isset($userroles[$roleid])) {
                // Add them.
                $id = role_assign($roleid, $userid, $context);
                // Keep this variable in sync.
                $role = new \stdClass();
                $role->id = $id;
                $role->roleid = $roleid;
                $role->contextid = $context->id;
                $userroles[$role->roleid] = $role;
            }
        }

        // Process removals.
        foreach ($assignableroles as $roleid => $rolename) {
            if (isset($userroles[$roleid]) && !isset($rolestoprocess[$roleid])) {
                // Do not remove the role if we are not in the same context.
                if ($userroles[$roleid]->contextid != $context->id) {
                    continue;
                }
                $ras = $DB->get_records('role_assignments', ['contextid' => $context->id, 'userid' => $userid,
                    'roleid' => $roleid]);
                $allremoved = true;
                foreach ($ras as $ra) {
                    if ($ra->component) {
                        if (strpos($ra->component, 'enrol_') !== 0) {
                            continue;
                        }
                        if (!$plugin = enrol_get_plugin(substr($ra->component, 6))) {
                            continue;
                        }
                        if ($plugin->roles_protected()) {
                            $allremoved = false;
                            continue;
                        }
                    }
                    role_unassign($ra->roleid, $ra->userid, $ra->contextid, $ra->component, $ra->itemid);
                }
                if ($allremoved) {
                    unset($userroles[$roleid]);
                }
            }
        }

        $course = get_course($courseid);
        $user = core_user::get_user($userid);
        return new self($course, $context, $user, $allroles, $assignableroles, $profileroles, $userroles, $viewableroles);
    }
1244028
public function casMember($member, $oldValue, $newValue)
    {
        $set = false;

        $this->lock();
        if ($this[$member] == $oldValue) {
            $this[$member] = $newValue;

            $set = true;
        }
        $this->unlock();

        return $set;
    }
595296
public function move($entity, $newPosition, $newParent = null) {
		extract($this->_config);

		if ($newParent !== null) {
			if($this->_scope($entity) !== ($parentScope = $this->_scope($newParent))) {
				$entity->set($parentScope);
			} elseif ($newParent->$left > $entity->$left && $newParent->$right < $entity->$right) {
				return false;
			}
			$parentId = $newParent->data($model::key());
			$entity->set([$parent => $parentId]);
			$entity->save();
			$parentNode = $newParent;
		} else {
			$newParent = $this->_getById($entity->$parent);
		}

		$childrenCount = $newParent->childrens(false, 'count');
		$position = $this->_getPosition($entity, $childrenCount);
		if ($position !== false) {
			$count = abs($newPosition - $position);

			for ($i = 0; $i < $count; $i++) {
				if ($position < $newPosition) {
					$entity->moveDown();
				} else {
					$entity->moveUp();
				}
			}
		}
		return true;
	}
673171
public function FormValues($NewValue = NULL) {
      if($NewValue !== NULL) {
         $this->_FormValues = $NewValue;
         return;
      }
      
      $MagicQuotes = get_magic_quotes_gpc();

      if (!is_array($this->_FormValues)) {
         $TableName = $this->InputPrefix;
         if(strlen($TableName) > 0)
            $TableName .= '/';
         $TableNameLength = strlen($TableName);
         $this->_FormValues = array();
         $Collection = $this->Method == 'get' ? $_GET : $_POST;
         $InputType = $this->Method == 'get' ? INPUT_GET : INPUT_POST;
         
         
         
         foreach($Collection as $Field => $Value) {
            $FieldName = substr($Field, $TableNameLength);
            $FieldName = $this->_UnescapeString($FieldName);
            if (substr($Field, 0, $TableNameLength) == $TableName) {
               if ($MagicQuotes) {
                  if (is_array($Value)) {
                     foreach ($Value as $i => $v) {
                        $Value[$i] = stripcslashes($v);
                     }
                  } else {
                     $Value = stripcslashes($Value);
                  }
               }
               
               $this->_FormValues[$FieldName] = $Value;
            }
         }
         
         // Make sure that unchecked checkboxes get added to the collection
         if (array_key_exists('Checkboxes', $Collection)) {
            $UncheckedCheckboxes = $Collection['Checkboxes'];
            if (is_array($UncheckedCheckboxes) === TRUE) {
               $Count = count($UncheckedCheckboxes);
               for($i = 0; $i < $Count; ++$i) {
                  if (!array_key_exists($UncheckedCheckboxes[$i], $this->_FormValues))
                     $this->_FormValues[$UncheckedCheckboxes[$i]] = FALSE;
               }
            }
         }
         
         // Make sure that Date inputs (where the day, month, and year are
         // separated into their own dropdowns on-screen) get added to the
         // collection as a single field as well...
         if (array_key_exists(
            'DateFields', $Collection) === TRUE) {
            $DateFields = $Collection['DateFields'];
            if (is_array($DateFields) === TRUE) {
               $Count = count($DateFields);
               for($i = 0; $i < $Count; ++$i) {
                  if (array_key_exists(
                     $DateFields[$i],
                     $this->_FormValues) ===
                      FALSE) // Saving dates in the format: YYYY-MM-DD
                     $Year = ArrayValue(
                        $DateFields[$i] .
                         '_Year',
                        $this->_FormValues,
                        0);
                  $Month = ArrayValue(
                     $DateFields[$i] .
                         '_Month',
                        $this->_FormValues,
                        0);
                  $Day = ArrayValue(
                     $DateFields[$i] .
                         '_Day',
                        $this->_FormValues,
                        0);
                  $Month = str_pad(
                     $Month,
                     2,
                     '0',
                     STR_PAD_LEFT);
                  $Day = str_pad(
                     $Day,
                     2,
                     '0',
                     STR_PAD_LEFT);
                  $this->_FormValues[$DateFields[$i]] = $Year .
                      '-' .
                      $Month .
                      '-' .
                      $Day;
               }
            }
         }
      }
      
      // print_r($this->_FormValues);
      return $this->_FormValues;
   }