# give/4.15.5/src/Framework/Migrations/Actions/ClearCompletedUpgrade.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.15.5. 34 lines.

- Page: https://pluginprobe.com/plugins/give/4.15.5/code/src/Framework/Migrations/Actions/ClearCompletedUpgrade.php
- Raw: https://pluginprobe.com/plugins/give/4.15.5/raw/src/Framework/Migrations/Actions/ClearCompletedUpgrade.php
- Modified: 2021-11-23T23:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.15.5/code/src/Framework/Migrations/Actions/ClearCompletedUpgrade.php#L10-L20`.

```php
<?php

namespace Give\Framework\Migrations\Actions;

use Give\Framework\Exceptions\Primitives\InvalidArgumentException;

/**
 * Class ClearCompletedUpgrade
 *
 * Clears an upgrade from the list of completed upgrades so it can be ran again
 */
class ClearCompletedUpgrade
{
    /**
     * @since 2.9.2
     *
     * @param string $upgradeId
     */
    public function __invoke($upgradeId)
    {
        $completedUpgrades = get_option('give_completed_upgrades');

        $upgradeIndex = array_search($upgradeId, $completedUpgrades, true);

        if (false === $upgradeIndex) {
            throw new InvalidArgumentException("No upgrade for the given ID: $upgradeId");
        }

        array_splice($completedUpgrades, $upgradeIndex, 1);

        update_option('give_completed_upgrades', $completedUpgrades);
    }
}

```
