Skip to content

Commit

Permalink
fix: clear applicator cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Dec 4, 2024
1 parent 69471e8 commit 58f87e5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
34 changes: 34 additions & 0 deletions library/Customizer/Applicators/Types/NullApplicator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* NullApplicator.php
*
* Build tor mocking and testing purposes.
*
* @package Municipio\Customizer\Applicators\Types
*/

namespace Municipio\Customizer\Applicators\Types;

use Municipio\Customizer\Applicators\ApplicatorInterface;

class NullApplicator implements ApplicatorInterface
{
// Return a fixed key for the NullApplicator
public function getKey(): string
{
return 'null_applicator';
}

// Return a simple empty array for getData()
public function getData(): array|string
{
return []; // No data to return
}

// Fake method to satisfy the interface, no actual data is applied
public function applyData(array|object $data)
{
// No-op: Do nothing with the data for the null implementation
}
}
16 changes: 15 additions & 1 deletion library/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use AcfService\Contracts\GetField;
use AcfService\Contracts\UpdateField;
use Municipio\Customizer\Applicators\Types\NullApplicator;
use WpService\Contracts\AddAction;
use WpService\Contracts\GetPostTypes;
use WpService\Contracts\GetThemeMod;
Expand All @@ -15,7 +16,7 @@
*/
class Upgrade
{
private $dbVersion = 36; //The db version we want to achive
private $dbVersion = 37; //The db version we want to achive
private $dbVersionKey = 'municipio_db_version';
private $db;

Expand Down Expand Up @@ -690,6 +691,19 @@ public function v_36($db): bool
return true;
}

public function v_37($db) {
$applicators = [
new NullApplicator($this->wpService),
];
$customizerCache = new \Municipio\Customizer\Applicators\ApplicatorCache(
$this->wpService,
$db,
...$applicators
);
$customizerCache->tryClearCache();
return true;
}

/**
* Get all post types
*
Expand Down

0 comments on commit 58f87e5

Please sign in to comment.