Remove SS 2.x upgrade code that runs every build

This commit is contained in:
Dylan Wagstaff 2018-01-29 15:26:16 +13:00
parent 7b38707fde
commit a25668eba0
2 changed files with 1 additions and 40 deletions

View File

@ -13,9 +13,3 @@ Then run a database rebuild by visiting `dev/build`. This will add the required
Out of the box the module adds commenting support to all pages on your site. This functionality can be turned on and off on a per page basis in the CMS under the `Behaviour` tab for a given page. Once the `Allow Comments` checkbox is ticked, republish and view the webpage.
For more configuration options see [Configuration](Configuration.md).
## Upgrading
### Migrating from version SilverStripe 2 installations
This module replaces the built-in commenting system available in SilverStripe 2. Running the `dev/build` task will automatically perform a migration if any comments from these old versions exist.

View File

@ -181,39 +181,6 @@ class Comment extends DataObject
return Injector::inst()->createWithArgs(SecurityToken::class, array($this));
}
/**
* Migrates the old {@link PageComment} objects to {@link Comment}
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Upgrade from SilverStripe 2 version if necessary
if (DB::get_schema()->hasTable('PageComment')) {
$comments = DB::query('SELECT * FROM "PageComment"');
if ($comments) {
while ($pageComment = $comments->next()) {
// create a new comment from the older page comment
$comment = new Comment();
$comment->update($pageComment);
// set the variables which have changed
$comment->BaseClass = SiteTree::class;
$comment->URL = (isset($pageComment['CommenterURL'])) ? $pageComment['CommenterURL'] : '';
if ((int) $pageComment['NeedsModeration'] == 0) {
$comment->Moderated = true;
}
$comment->write();
}
}
DB::alteration_message('Migrated PageComment to Comment', 'changed');
DB::get_schema()->dontRequireTable('PageComment');
}
}
/**
* Return a link to this comment
*