From: Roland Haeder Date: Sun, 3 Jan 2016 17:55:37 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' into social-master X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e2d85a39e7f82ceef2cb2fe66a3a9a62ac9a363e;p=quix0rs-gnu-social.git Merge remote-tracking branch 'upstream/master' into social-master Signed-off-by: Roland Haeder --- e2d85a39e7f82ceef2cb2fe66a3a9a62ac9a363e diff --cc plugins/Event/classes/Happening.php index 9962815a67,9ef288eca4..fd8c3c8a2a --- a/plugins/Event/classes/Happening.php +++ b/plugins/Event/classes/Happening.php @@@ -202,14 -200,19 +200,19 @@@ class Happening extends Managed_DataObj return $this->url; } + public function getUri() + { + return $this->uri; + } + function getNotice() { - return Notice::getKV('uri', $this->uri); + return Notice::getKV('uri', $this->getUri()); } - static function fromNotice($notice) + static function fromNotice(Notice $notice) { - return Happening::getKV('uri', $notice->uri); + return Happening::getKV('uri', $notice->getUri()); } function getRSVPs() diff --cc plugins/Event/classes/RSVP.php index 6a6f7f3811,520347eeb6..c4ffc3ee34 --- a/plugins/Event/classes/RSVP.php +++ b/plugins/Event/classes/RSVP.php @@@ -107,7 -91,40 +91,40 @@@ class RSVP extends Managed_DataObjec ); } + static public function beforeSchemaUpdate() + { + $table = strtolower(get_called_class()); + $schema = Schema::get(); + $schemadef = $schema->getTableDef($table); + + // 2015-12-31 RSVPs refer to Happening by event_uri now, not event_id. Let's migrate! + if (isset($schemadef['fields']['event_uri'])) { + // We seem to have already migrated, good! + return; + } + + // this is a "normal" upgrade from StatusNet for example + echo "\nFound old $table table, upgrading it to add 'event_uri' field..."; + + $schemadef['fields']['event_uri'] = array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'Event URI'); + $schema->ensureTable($table, $schemadef); + + $rsvp = new RSVP(); + $rsvp->find(); + while ($rsvp->fetch()) { + $event = Happening::getKV('id', $rsvp->event_id); + if (!$event instanceof Happening) { + continue; + } + $orig = clone($rsvp); + $rsvp->event_uri = $event->uri; + $rsvp->updateWithKeys($orig); + } + print "DONE.\n"; + print "Resuming core schema upgrade..."; + } + - function saveNew($profile, $event, $verb, $options=array()) + function saveNew(Profile $profile, $event, $verb, array $options = array()) { if (array_key_exists('uri', $options)) { $other = RSVP::getKV('uri', $options['uri']);