LinkProtection/migrations/release_1_1_0.php

40 lines
780 B
PHP
Executable file

<?php
namespace pedodev\linkprotection\migrations;
class release_1_1_0 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['pedodev_linkprotection_fileprefix']);
}
static public function depends_on()
{
return ['\phpbb\db\migration\data\v330\v330'];
}
public function update_data()
{
$file_prefix = bin2hex(random_bytes(8));
return [
// The prefix we will add to our automatic links JSON file
['config.add', ['pedodev_linkprotection_fileprefix', $file_prefix]],
];
}
public function revert_data()
{
$filepath = __DIR__ . "/../automatic_links_{$this->config['pedodev_linkprotection_fileprefix']}.json";
if (file_exists($filepath))
{
unlink($filepath);
}
return [];
}
}