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

Provisioning script's default homepage doesn't play nice with some WP-CLI commands #39

Open
leonstafford opened this issue Jun 11, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@leonstafford
Copy link
Contributor

I use this to set the default homepage on a new Lokl site:

  wp post update 1 --post_title="Getting started with Lokl"                     
  wp post update 1 --post_content="Use this site as your starting point or import content from an existing site. <a href='/wp-admin'>View Dashboard</a>"
  wp option update page_on_front 1                                              
  wp option update show_on_front "page" 

This works as I intended, but doesn't look like a valid WP config, as post ID 1 is a Post, not a Page.

When going to Settings > Reading, we can see the radio for A static page vs Your latest posts, but neither of the dropdown options are selected.

When running wp profile stage, the following errors are seen:

Warning: Some code is trying to do a URL redirect. Backtrace:
#0 WP_CLI\Utils\wp_redirect_handler(http://localhost:4967/hello-world/) called at [/usr/html/wp-includes/class-wp-hook.php:294]
#1 WP_Hook->apply_filters(http://localhost:4967/hello-world/, Array ([0] => http://localhost:4967/hello-world/,[1] => 301)) called at [/usr/html/wp-includes/plugin.php:212]
#2 apply_filters(wp_redirect, http://localhost:4967/hello-world/, 301) called at [/usr/html/wp-includes/pluggable.php:1290]
#3 wp_redirect(http://localhost:4967/hello-world/, 301) called at [/usr/html/wp-includes/canonical.php:799]
#4 redirect_canonical(http://localhost:4967/) called at [/usr/html/wp-includes/class-wp-hook.php:292]
#5 WP_Hook->apply_filters(, Array ([0] => )) called at [/usr/html/wp-includes/class-wp-hook.php:316]
#6 WP_Hook->do_action(Array ([0] => )) called at [/usr/html/wp-includes/plugin.php:484]
#7 do_action(template_redirect) called at [/usr/html/wp-includes/template-loader.php:13]
#8 require_once(/usr/html/wp-includes/template-loader.php) called at [/root/.wp-cli/packages/vendor/wp-cli/profile-command/src/Profiler.php:474]
#9 WP_CLI\Profile\Profiler->load_wordpress_with_template() called at [/root/.wp-cli/packages/vendor/wp-cli/profile-command/src/Profiler.php:126]
#10 WP_CLI\Profile\Profiler->run() called at [/root/.wp-cli/packages/vendor/wp-cli/profile-command/src/Command.php:110]
#11 WP_CLI\Profile\Command->stage(Array (), Array ([format] => table,[order] => ASC))
#12 call_user_func(Array ([0] => WP_CLI\Profile\Command Object (),[1] => stage), Array (), Array ([format] => table,[order] => ASC)) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:100]
#13 WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}(Array (), Array ([format] => table,[order] => ASC))
#14 call_user_func(Closure Object (), Array (), Array ([format] => table,[order] => ASC)) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:491]
#15 WP_CLI\Dispatcher\Subcommand->invoke(Array (), Array ([format] => table,[order] => ASC), Array ()) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:399]
#16 WP_CLI\Runner->run_command(Array ([0] => profile,[1] => stage), Array ()) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:422]
#17 WP_CLI\Runner->run_command_and_exit() called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:107]
#18 WP_CLI\Runner->do_early_invoke(before_wp_load) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1136]
#19 WP_CLI\Runner->start() called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php:23]
#20 WP_CLI\Bootstrap\LaunchRunner->process(WP_CLI\Bootstrap\BootstrapState Object ([WP_CLI\Bootstrap\BootstrapStatestate] => Array ())) called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php:77]
#21 WP_CLI\bootstrap() called at [phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php:27]
#22 include(phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php) called at [phar:///usr/bin/wp/php/boot-phar.php:11]
#23 include(phar:///usr/bin/wp/php/boot-phar.php) called at [/usr/bin/wp:4]

Common WP-CLI don't seem to be affected yet, but this is a bug in Lokl's default site example that should be fixed.

@leonstafford leonstafford added the bug Something isn't working label Jun 11, 2021
@leonstafford
Copy link
Contributor Author

quick workaround is to set wp option update page_on_front 2, which sets it to a Page vs a Post

consider reporting issue to WP-CLI in that it should warn / error if setting homepage to invalid post ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant