Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when blueprint includes themeInstall step for latest WordPress default theme #1157

Closed
ndiego opened this issue Mar 29, 2024 · 2 comments · Fixed by #1244
Closed

Error when blueprint includes themeInstall step for latest WordPress default theme #1157

ndiego opened this issue Mar 29, 2024 · 2 comments · Fixed by #1244
Labels
[Package][@wp-playground] Blueprints [Type] Bug An existing feature does not function as intended

Comments

@ndiego
Copy link
Member

ndiego commented Mar 29, 2024

If your blueprint includes a step for themeInstall that includes the latest WordPress theme, which is currently TT4, you get an error because the theme is already installed. Also, if there are steps following the themeInstall step, they won't get triggered due to the error.

Here's an example blueprint.

{
    "$schema": "https://playground.wordpress.net/blueprint-schema.json",
    "features": {
        "networking": true
    },
    "steps": [
        {
            "step": "login"
        },
        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "wordpress.org\/themes",
                "slug": "twentytwentyfour"
            }
        }
    ]
}

And here's the resulting error.
image

Perhaps if there's a step that installs a theme or plugin that already exists by default in Playground, the step is ignored.

@ndiego ndiego added the [Type] Bug An existing feature does not function as intended label Mar 29, 2024
@adamziel adamziel added this to the Zero Crashes milestone Mar 29, 2024
@adamziel
Copy link
Collaborator

Good point @ndiego! I think the step should still execute because the theme might have a newer version than the bundled one. Removing the bundled theme and logging a console.warning could be a good solution.

In the meantime, you could use this as a workaround:

{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "features": {
    "networking": true
  },
  "steps": [
    {
      "step": "login"
    },
    {
      "step": "rmdir",
      "path": "/wordpress/wp-content/themes/twentytwentyfour"
    },
    {
      "step": "installTheme",
      "themeZipFile": {
        "resource": "wordpress.org/themes",
        "slug": "twentytwentyfour"
      }
    }
  ]
}

@ndiego
Copy link
Member Author

ndiego commented Mar 29, 2024

I think the step should still execute because the theme might have a newer version than the bundled one. Removing the bundled theme and logging a console.warning could be a good solution.

Yeah great point!

adamziel added a commit that referenced this issue Apr 16, 2024
…steps (#1244)

Adds an `ifAlreadyInstalled?: 'overwrite' | 'skip' | 'error'` option to
installPlugin and installTheme steps. It defaults to `overwrite`.

Consider the following Blueprint:

```json
{
    "preferredVersions": {
        "php": "latest",
        "wp": "6.4"
    },
    "steps": [
        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "wordpress.org/themes",
                "slug": "twentytwentyfour"
            }
        }
    ]
}
```

Before this PR, it would result in an error. After this PR, the
installation just works. If the Blueprint author explicitly wants the
installation to fail, they can specify the `ifAlreadyInstalled` option:

```json
{
    "steps": [
        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "wordpress.org/themes",
                "slug": "twentytwentyfour"
            },
            "ifAlreadyInstalled": "skip" // or "error"
        }
    ]
}
```

## Motivation

Installing a plugin or theme over a currently installed one is a common
gotcha. Currently it results in an error and blocks the Blueprint
execution. This behavior is, however, often undesirable as it prevents
having a single Blueprint that installs a twentytwentyfour theme on
different versions of WordPress.

An addition of the `ifAlreadyInstalled` option puts the Blueprint author
in control and provides a sensible default behavior where the
installation will "just work" by replacing the already installed version
of the plugin or theme.

Closes #1157
Related to WordPress/blueprints#19

 ## Testing instructions

Confirm the unit tests pass

cc @bgrgicak @brandonpayton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package][@wp-playground] Blueprints [Type] Bug An existing feature does not function as intended
Projects
Archived in project
3 participants