- Gets the current collection from DB with ModinfoX2DBReader.
- Gets the latest collection form xoops_version with ModinfoX2FileReader.
- Update the current collection with the latest collection.
In these process, the current collection merges the latest collection without losing values if at all possible.
Let's see BlockInfoCollection::update().
function update(&$collection)
{
foreach (array_keys($this->mBlocks) as $idx) {
$t_block =& $collection->get($this->mBlocks[$idx]->mFuncNum);
if ($t_block == null) {
if (!$collection->funcExists($this->mBlocks[$idx])) {
$this->mBlocks[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_DELETED;
} else {
$this->mBlocks[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_UPDATED;
}
}
elseif (!$this->mBlocks[$idx]->isEqual($t_block)) {
$this->mBlocks[$idx]->update($t_block);
}
}
foreach (array_keys($collection->mBlocks) as $idx) {
$func_num = $collection->mBlocks[$idx]->mFuncNum;
if (!isset($this->mBlocks[$func_num])) {
$this->add($collection->mBlocks[$idx]);
$this->mBlocks[$func_num]->mStatus = LEGACY_INSTALLINFO_STATUS_NEW;
}
}
}
BlockInfoCollection::get() is useful to check whether another collection has the same information structure as this collection. If another collection doesn't return an instance with the same key, this block has been deleted in the latest version. In this case, changes the status of the information to "deleted". Because the collection doesn't know how to delete data from a resource, it doesn't have the process to delete. There are several kinds of status.
No comments:
Post a Comment