Restore some fields after the pagination count.

@return void
430203
protected function restoreFieldsForCount()
	{
		foreach (['orders', 'limit', 'offset', 'columns'] as $field)
		{
			$this->{$field} = $this->backups[$field];
		}

		$this->backups = [];
	}
1017857
function restoreState( $pageEnd = 0 )
    {
        if ( !$pageEnd )
        {
            $n = $this->nStateStack;
            $this->currentColour = $this->stateStack[$n]['col'];
            $this->currentStrokeColour = $this->stateStack[$n]['str'];
            $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin'];
            $this->currentLineStyle = $this->stateStack[$n]['lin'];
            unset( $this->stateStack[$n] );
            $this->nStateStack--;
        }
        $this->objects[$this->currentContents]['c'] .= "\nQ";
    }
562947
public function generateRemovedFields()
    {
        foreach ($this->keptModelKeys as $modelName) {
            $oldFieldKeys = $this->oldFieldKeys[$modelName];
            $newFieldKeys = $this->newFieldKeys[$modelName];

            $remFields = array_diff($oldFieldKeys, $newFieldKeys);

            foreach ($remFields as $remField) {
                $this->findRemovedFields($modelName, $remField);
            }
        }
    }
124675
public function afterUpdate()
    {
        //only clean and change custom fields if they are been sent
        if (!empty($this->customFields)) {
            //replace old custom with new
            $allCustomFields = $this->getAllCustomFields();
            if (is_array($allCustomFields)) {
                foreach ($this->customFields as $key => $value) {
                    $allCustomFields[$key] = $value;
                }
            }

            //set
            $this->setCustomFields($allCustomFields);
            //clean old
            $this->cleanCustomFields($this->getId());
            //save new
            $this->saveCustomFields();
        }
    }
1350958
protected function updateOrderFieldOnRestore()
    {
        static::orderModel()
            ->where($this->getOrderField(), '>', $this->getOrderValue())
            ->increment($this->getOrderField());
    }
122013
protected function afterDelete()
    {
        parent::afterDelete();

        if ($this->obElement->active) {
            $this->clearProductActiveList();
            $this->clearProductItemCache($this->obElement->product_id);
            OfferListStore::instance()->active->clear();

            $this->clearOfferSortingByPrice();

            //Clear sorting product list by offer price
            $this->clearProductSortingByPrice();
        }

        OfferListStore::instance()->sorting->clear(OfferListStore::SORT_NO);
        OfferListStore::instance()->sorting->clear(OfferListStore::SORT_NEW);
    }
25646
protected function afterDelete()
    {
        parent::afterDelete();
        $this->clearSortingList();

        if ($this->obElement->active) {
            TaxListStore::instance()->active->clear();
        }
    }
570159
public function afterInit()
    {
        $this->addField('name', ['default'=> $this->lookupField->short_name, 'system' => true]);

        if (isset($this->_sessionTrait) && $this->_sessionTrait) {
            // create a name for our filter model to save as session data.
            $this->name = 'filter_model_'.$this->lookupField->short_name;

            if (@$_GET['atk_clear_filter']) {
                $this->forget();
            }

            if ($data = $this->recallData()) {
                $this->persistence->data['data'][] = $data;
            }

            // Add hook in order to persist data in session.
            $this->addHook('afterSave', function ($m) {
                $this->memorize('data', $m->get());
            });
        }
    }
403783
public function afterDelete()
    {
        $this->user->extend->updateCounters(['questions' => -1]);
        Answer::deleteAll(['question_id' => $this->id]);
        parent::afterDelete();
    }
369815
protected function afterSave()
    {
        parent::afterSave();

        if ($this->isFieldChanged('date_begin')) {
            PromoBlockListStore::instance()->sorting->clear(PromoBlockListStore::SORT_DATE_BEGIN_ASC);
            PromoBlockListStore::instance()->sorting->clear(PromoBlockListStore::SORT_DATE_BEGIN_DESC);
        }

        if ($this->isFieldChanged('date_end')) {
            PromoBlockListStore::instance()->sorting->clear(PromoBlockListStore::SORT_DATE_END_ASC);
            PromoBlockListStore::instance()->sorting->clear(PromoBlockListStore::SORT_DATE_END_DESC);
        }

        $this->checkFieldChanges('hidden', PromoBlockListStore::instance()->hidden);
        $this->checkFieldChanges('hidden', PromoBlockListStore::instance()->not_hidden);

        $this->checkFieldChanges('active', PromoBlockListStore::instance()->active);
    }
853954
public function afterDelete()
    {
        parent::afterDelete();
        Comment::deleteAll(['model' => self::COMMENT_FOR, 'parent_id' => $this->id]);
        Tag::updateFrequency($this->tags, '');
        PostAuthor::updateAuthors($this->id, $this->_oldAuthors, []);
    }
680460
public function getPaginationCount()
	{
		list($orders, $this->orders) = array($this->orders, null);

		$columns = $this->columns;

		// Because some database engines may throw errors if we leave the ordering
		// statements on the query, we will "back them up" and remove them from
		// the query. Once we have the count we will put them back onto this.
		$total = $this->count();

		$this->orders = $orders;

		// Once the query is run we need to put the old select columns back on the
		// instance so that the select query will run properly. Otherwise, they
		// will be cleared, then the query will fire with all of the columns.
		$this->columns = $columns;

		return $total;
	}
716190
function paging()
    {
        $this->num = $this->count();
        $offset = ($this->page - 1) * $this->page_size;
        if ($offset < 0)
        {
            $offset = 0;
        }
        if ($this->num % $this->page_size > 0)
        {
            $this->pages = intval($this->num / $this->page_size) + 1;
        }
        else
        {
            $this->pages = $this->num / $this->page_size;
        }
        $this->limit($offset . ',' . $this->page_size);
        $this->pager = new Pager(array('total'    => $this->num,
                                       'perpage'  => $this->page_size,
                                       'nowindex' => $this->page
        ));
    }
1060150
public function after_restore() {
        global $DB;

        // Get the blockid.
        $blockid = $this->get_blockid();

        // Extract block configdata and remove tag collection reference if this is another site. Also map contextid.
        if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
            $config = unserialize(base64_decode($configdata));
            $changed = false;
            if (!empty($config->tagcoll) && $config->tagcoll > 1 && !$this->is_samesite()) {
                $config->tagcoll = 0;
                $changed = true;
            }
            if (!empty($config->ctx)) {
                if ($ctxmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'context', $config->ctx)) {
                    $config->ctx = $ctxmap->newitemid;
                } else {
                    $config->ctx = 0;
                }
                $changed = true;
            }
            if ($changed) {
                $configdata = base64_encode(serialize($config));
                $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
            }
        }
    }
240906
protected function generateEntitiesListFromQuery(): void
    {
        $query = $this->getAttribute('tableModel')->query();
        $this->applyQueryClosure($query);
        $this->checkColumnsValidity();
        $this->applySearchClauses($query);
        $this->applySortClauses($query);
        $this->paginateList($query);
        $this->applyClosuresOnPaginatedList();
    }
509660
public function restore()
    {
        if ($this->intStoredErrorLevel !== null) {
            if ($this->intStoredErrorLevel != -1) {
                error_reporting($this->intStoredErrorLevel);
            }
            restore_error_handler();
            $this->intStoredErrorLevel = null;
        }
    }
696168
public function afterDelete()
    {
        if ($this->cover)
        {
            /** @var Gallery_Entity_Table_Image $table  */
            $table = $this->getTable();
            $table->autoSetCover($this->section);
        }
    }