Skip to content

Commit

Permalink
API Remove deprecated code (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabina-talipova authored Jan 25, 2023
1 parent e5162c8 commit c20c342
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions code/AuditHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace SilverStripe\Auditor;

use SilverStripe\Dev\Deprecation;
use SilverStripe\Control\Email\Email;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\Connect\Database;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectSchema;
Expand All @@ -31,56 +29,6 @@ protected function getAuditLogger()
return Injector::inst()->get('AuditLogger');
}

/**
* This will bind a new class dynamically so we can hook into manipulation
* and capture it. It creates a new PHP file in the temp folder, then
* loads it and sets it as the active DB class.
*
* @deprecated 2.1.0 Use ProxyDBExtension with the tractorcow/silverstripe-proxy-db module instead
*/
public static function bind_manipulation_capture()
{
Deprecation::notice('2.1.0', 'Use ProxyDBExtension with the tractorcow/silverstripe-proxy-db module instead');
$current = DB::get_conn();
if (!$current || !$current->getConnector()->getSelectedDatabase() || @$current->isManipulationLoggingCapture) {
return;
} // If not yet set, or its already captured, just return

$type = get_class($current);
$sanitisedType = str_replace('\\', '_', $type ?? '');
$file = TEMP_FOLDER . "/.cache.CLC.$sanitisedType";
$dbClass = 'AuditLoggerManipulateCapture_' . $sanitisedType;

if (!is_file($file ?? '')) {
file_put_contents($file ?? '', "<?php
class $dbClass extends $type
{
public \$isManipulationLoggingCapture = true;
public function manipulate(\$manipulation)
{
\SilverStripe\Auditor\AuditHook::handle_manipulation(\$manipulation);
return parent::manipulate(\$manipulation);
}
}
");
}

require_once $file;

/** @var Database $captured */
$captured = new $dbClass();

$captured->setConnector($current->getConnector());
$captured->setQueryBuilder($current->getQueryBuilder());
$captured->setSchemaManager($current->getSchemaManager());

// The connection might have had it's name changed (like if we're currently in a test)
$captured->selectDatabase($current->getConnector()->getSelectedDatabase());

DB::set_conn($captured);
}

public static function handle_manipulation($manipulation)
{
$auditLogger = Injector::inst()->get('AuditLogger');
Expand Down Expand Up @@ -394,17 +342,6 @@ public function authenticationFailed($data)
$this->getAuditLogger()->info(sprintf('Failed login attempt using email "%s"', $login));
}

/**
* @deprecated 2.1.0 Use tractorcow/silverstripe-proxy-db instead
*/
public function onBeforeInit()
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('2.1.0', 'Use tractorcow/silverstripe-proxy-db instead');
});
// no-op
}

/**
* Log permission failures (where the status is set after init of page).
*/
Expand Down

0 comments on commit c20c342

Please sign in to comment.