Author: sevein
Date: Sun Jul 22 22:28:25 2012
New Revision: 11957
Log:
Implemente case 63, case 74 has been optimized but it may be interesting to
optimize also the publication status lookup. Case 70 has not been tested yet.
Modified:
trunk/lib/task/migrate/arUpgrader110.class.php
Modified: trunk/lib/task/migrate/arUpgrader110.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgrader110.class.php Sun Jul 22 22:13:24
2012 (r11956)
+++ trunk/lib/task/migrate/arUpgrader110.class.php Sun Jul 22 22:28:25
2012 (r11957)
@@ -32,6 +32,9 @@
public function up($version, $configuration)
{
+ // This upgrader class is a port of QubitMigrate110
+ // updateSchema() introduces the SQL schema changes that did not
+ // fit in any existing db upgrade method
if (self::INIT_VERSION == $version)
{
$this->updateSchema($configuration);
@@ -415,16 +418,48 @@
// Migrate relation notes for date and description to relation_i18n table
case 63:
+ $sql = sprintf('SELECT id FROM note WHERE note.type_id IN (%s, %s)',
+ QubitTerm::RELATION_NOTE_DATE_ID,
+ QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
+ $stmt = QubitPdo::prepareAndExecute($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_NUM))
+ {
+ $note = QubitNote::getById($row[0]);
+
+ if (null === $relation = QubitRelation::getById($note->objectId))
+ {
+ continue;
+ }
+
+ $relation->sourceCulture = $note->sourceCulture;
- echo "63 ------------- TODO\n";
+ switch ($note->typeId)
+ {
+ case QubitTerm::RELATION_NOTE_DATE_ID:
+ $relation->date = $note->getContent(array('sourceCulture' =>
true));
+
+ break;
+
+ case QubitTerm::RELATION_NOTE_DESCRIPTION_ID:
+ $relation->description = $note->getContent(array('sourceCulture'
=> true));
+
+ break;
+ }
+
+ $relation->save();
+
+ $note->delete();
+
+ // Clear internal objects cache
+ QubitRelation::clearCache();
+ QubitNote::clearCache();
+ }
break;
// Prior to r9340 all checksums were md5 and the algorithm was not
// recorded, update checksum_type column
case 64:
-
- // Set value md5 in some cases
$sql = 'UPDATE '.QubitDigitalObject::TABLE_NAME;
$sql .= ' SET '.QubitDigitalObject::CHECKSUM_TYPE.' = "md5"';
$sql .= ' WHERE CHAR_LENGTH(checksum_type) > 0';
@@ -512,7 +547,7 @@
break;
// Move digital objects to repository specific paths like r9503
- case 70:
+ case 70: echo "TODO case 70 NEEDS TESTING\n";
if (!file_exists(sfConfig::get('sf_upload_dir').'/r'))
{
mkdir(sfConfig::get('sf_upload_dir').'/r', 0775);
@@ -662,15 +697,20 @@
break;
// Ensure all information objects get an explicit publication status
- case 74:
- $criteria = new Criteria;
- $criteria->add(QubitInformationObject::ID,
QubitInformationObject::ROOT_ID, Criteria::NOT_EQUAL);
- foreach (QubitInformationObject::get($criteria) as $item)
+ case 74: echo "TODO case 74 OPTIMIZE STATUS/ANCESTORS LOOKUP\n";
+ $sql = '
+ SELECT id
+ FROM information_object
+ WHERE
+ information_object.parent_id IS NOT NULL
+ AND (SELECT COUNT(id) FROM status
+ WHERE
+ status.object_id = information_object.id AND
+ status.type_id = '.QubitTerm::STATUS_TYPE_PUBLICATION_ID.') <
1';
+ $stmt = QubitPdo::prepareAndExecute($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
- if (null !== $item->getPublicationStatus())
- {
- continue;
- }
+ $item = QubitInformationObject::getById($row[0]);
// Ascend up object hierarchy until a publication status is found
// right up to the root object if necessary (which is set to 'draft'
by default)
@@ -680,10 +720,14 @@
if (isset($status) && null !== $status->statusId)
{
$item->setPublicationStatus($status);
+ $item->save();
continue;
}
}
+
+ QubitInformationObject::clearCache();
+ QubitStatus::clearCache();
}
break;
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.