Update Check

Inject blob-common into the Core update list whenever updates
are available.

@param object $updates Updates.
@return object $updates Updates.
171533
public static function update_plugins($updates) {
		// Most of the time we don't actually need to do anything.
		if (
			! \is_object($updates) ||
			! isset($updates->response) ||
			isset($updates->response['blob-common/index.php']->new_version) ||
			(false === ($me = static::check_plugin())) ||
			! $me['Version'] ||
			! $me['DownloadVersion'] ||
			! $me['DownloadURI'] ||
			\version_compare($me['Version'], $me['DownloadVersion']) >= 0
		) {
			return $updates;
		}

		// Add ourselves to the list!
		$updates->response[static::PLUGIN_PATH] = new stdClass();
		$updates->response[static::PLUGIN_PATH]->id = 0;
		$updates->response[static::PLUGIN_PATH]->new_version = $me['DownloadVersion'];
		$updates->response[static::PLUGIN_PATH]->package = $me['DownloadURI'];
		$updates->response[static::PLUGIN_PATH]->plugin = 'blob-common/index.php';
		$updates->response[static::PLUGIN_PATH]->slug = $me['TextDomain'];
		$updates->response[static::PLUGIN_PATH]->url = $me['PluginURI'];

		return $updates;
	}
1332270
public function update(array $fields = []) {
        $query = new UpdateQuery($this->getTable());
        $query->fields(!empty($fields)? $fields : $this->getFields());
        $query->whereConditionGroup($this->getWhereConditionGroup());
        return $this->connection->exec($query);
    }
1076551
public function setChanges($changes)
    {
        if ($changes instanceof Records) {
            $this->changes = $changes;
        } else {
            if (is_array($changes)) {
                $changes       = new Records($changes);
                $this->changes = $changes;
            }
        }
        return $this;
    }
855692
public function allow_minor_auto_core_updates( $update ) {
		if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) {
			return $update;
		}

		return $update || ! empty( $this->settings['wpcore']['all'] ) ||
			! empty( $this->settings['wpcore']['minor'] );
	}
550897
public function update($set = array())
    {
        if (is_array($set)) {
            $params = array();
            foreach ($set as $field => $param) {
                $this->add('set', $field . ' = ?', true);
                $params[] = $param;
            }
            $this->params = array_merge($params, $this->params);
        } else {
            $this->add('set', $set, true);
        }
        $this->type = self::UPDATE;
        return $this->execute();
    }
537527
public function getUpdates(array $params = [])
    {
        return array_map(function (stdClass $update) {
            return Update::create($update);
        }, $this->request('getUpdates', $params)->getResult());
    }
1280189
public function forVersions(VersionsCollection $versions) : Version
    {
        Assert::that($versions->count())
            ->greaterThan(0, 'Cannot determine latest minor version from an empty collection');

        $stableVersions = $versions->matching(new class implements ConstraintInterface {
            public function assert(Version $version) : bool
            {
                return ! $version->isPreRelease();
            }
        });

        $versionsSortedDescending = $stableVersions->sortedDescending();

        /** @var Version $lastVersion */
        $lastVersion = array_values(iterator_to_array($versionsSortedDescending))[0];

        $matchingMinorVersions = $stableVersions
            ->matching(new CompositeConstraint(
                CompositeConstraint::OPERATOR_AND,
                new ComparisonConstraint(ComparisonConstraint::OPERATOR_LTE, $lastVersion),
                new ComparisonConstraint(
                    ComparisonConstraint::OPERATOR_GTE,
                    Version::fromString($lastVersion->getMajor() . '.' . $lastVersion->getMinor() . '.0')
                )
            ))
            ->sortedAscending();

        /** @var Version[] $matchingMinorVersionsAsArray */
        $matchingMinorVersionsAsArray = array_values(iterator_to_array($matchingMinorVersions));

        return $matchingMinorVersionsAsArray[0];
    }
983191
public function update(array $fields = [])
    {
        $connection = $this->getConnection();

        $this->beforeUpdateInternal();

        $connection->beginTransaction();
        try {
            if ($updated = $this->updateInternal($fields)) {
                $connection->commit();
            } else {
                $connection->rollBack();
            }
        } catch (Exception $e) {
            $connection->rollBack();
            throw $e;
        }

        $this->afterUpdateInternal();

        if ($updated) {
            $this->updateRelated();
            $this->attributes->resetOldAttributes();
        }

        return $updated;
    }
828993
public function update($fields) {
        if (is_array($fields)) {
            foreach ($fields as $key => $value) {
                if (is_string($value)) {
                    array_push($this->_updates, $key . ' = \'' . addslashes($value) . '\'');
                } else {
                    array_push($this->_updates, $key . ' = ' . $value);
                }
            }
        } else {
            return false;
        }
        
        $sql_query = 'UPDATE ' . $this->_table . 
                     ' SET ' . implode($this->_updates, ', ');
        
        // Where statements
        if (count($this->_where)) {
            $sql_query .= ' WHERE ';
            $sql_query .= implode($this->_where, ' AND ');
            
            // or statements
            if (count($this->_or)) {
                $sql_query .= ' OR ';
                $sql_query .= implode($this->_or, ' AND ');
            }
        }
        
        // Set the query
        $this->_sql_query = $sql_query;
        
        return $this;
    }
1024297
public function update($models)
    {
        if ($models->isEmpty()) {
            return;
        }

        $index = $this->algolia->initIndex($models->first()->searchableAs());

        if ($this->usesSoftDelete($models->first()) && $this->softDelete) {
            $models->each->pushSoftDeleteMetadata();
        }

        $objects = $models->map(function ($model) {
            if (empty($searchableData = $model->toSearchableArray())) {
                return;
            }

            return array_merge(
                ['objectID' => $model->getScoutKey()],
                $searchableData,
                $model->scoutMetadata()
            );
        })->filter()->values()->all();

        if (! empty($objects)) {
            $index->saveObjects($objects);
        }
    }
358136
public function update(array $data, array $files = [])
    {
        if ($data) {
            $blueprint = $this->getBlueprint();

            // Process updated data through the object filters.
            $this->filterElements($data);

            // Get currently stored data.
            $elements = $this->getElements();

            // Merge existing object to the test data to be validated.
            $test = $blueprint->mergeData($elements, $data);

            // Validate and filter elements and throw an error if any issues were found.
            $blueprint->validate($test + ['storage_key' => $this->getStorageKey(), 'timestamp' => $this->getTimestamp()]);
            $data = $blueprint->filter($data, false, true);

            // Finally update the object.
            foreach ($blueprint->flattenData($data) as $key => $value) {
                if ($value === null) {
                    $this->unsetNestedProperty($key);
                } else {
                    $this->setNestedProperty($key, $value);
                }
            }

            // Store the changes
            $this->_changes = Utils::arrayDiffMultidimensional($this->getElements(), $elements);
        }

        if ($files && method_exists($this, 'setUpdatedMedia')) {
            $this->setUpdatedMedia($files);
        }

        return $this;
    }
713334
public function insert(array $sets)
    {
        $this->builderCache->store('sets', $sets);

        return $this->platformInsertHandler($this->builderCache);
    }
1029296
private function _createBonusOperation($updates)
    {
        $asCustId = 'asCid';
        $asAmount = 'asAmnt';
        $asRef = 'asRef';
        $transData = [];
        foreach ($updates as $custId => $sales) {
            foreach ($sales as $saleId => $amount) {
                $item = [$asCustId => $custId, $asAmount => $amount, $asRef => $saleId];
                $transData[] = $item;
            }
        }
        $req = new WalletOperationAddToWalletActiveRequest();
        $req->setAsCustomerId($asCustId);
        $req->setAsAmount($asAmount);
        $req->setAsRef($asRef);
        $req->setOperationTypeCode(Cfg::CODE_TYPE_OPER_BONUS_LOYALTY);
        $req->setTransData($transData);
        $result = $this->callWalletOperation->addToWalletActive($req);
        return $result;
    }
839137
public function rawUpdateById(Update $update, $id)
        {
            if (!$id) {
                return null;
            }

            $query = new Query($this);
            $query->where($this->id_column, $id);
            $query->setLimit(1);
            $query->generateUpdateSQL($update);

            $value = Statement::getPreparedStatement($query)->execute();
            $this->deleteB2DBObjectFromCache($id);

            return $value;
        }
574194
public function dbgInsertMany(array $rows, array $update=[], array $constraint=[]) {
		$sql = $this->buildInsertSQL($rows, $update, $constraint);
		$params = $this->getParameters();

		return $this->replaceParams($sql, $params);
	}
613875
protected function buildUpdateUpdatePayload(Update $update)
    {
        $payload = array(
            'text' => $update->text,
            'now' => $update->now,
        );

        if ( ! empty($update->media)) {
            $payload['media'] = $update->media;
        }

        if ( ! is_null($update->scheduled_at)) {
            $payload['scheduled_at'] = $update->scheduled_at;
        }

        return $payload;
    }
533492
static public function updateOrCreateRecords(array $records) {
        $table = static::getInstance();
        $alreadyInTransaction = $table::inTransaction();
        if (!$alreadyInTransaction) {
            $table::beginTransaction();
        }
        try {
            foreach ($records as $record) {
                $success = $table::updateOrCreateRecord($record);
                if (!$success) {
                    if (!$alreadyInTransaction) {
                        $table::rollBackTransaction();
                    }
                    return false;
                }
            }
            if (!$alreadyInTransaction) {
                $table::commitTransaction();
            }
            return true;
        } catch (\Exception $exc) {
            if (!$alreadyInTransaction && $table::inTransaction()) {
                $table::rollBackTransaction();
            }
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            throw $exc;
        }
    }