mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Remove SS 2.x upgrade code that runs every build
This commit is contained in:
parent
7b38707fde
commit
a25668eba0
@ -12,10 +12,4 @@ 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.
|
||||
For more configuration options see [Configuration](Configuration.md).
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user