pantheon-systems / terminus

The Pantheon CLI — a standalone utility for performing operations on the Pantheon Platform
https://pantheon.io
Other
316 stars 194 forks source link

Can't perform http:// to https:// search-replace with terminus wp command? #1692

Open ghost opened 7 years ago

ghost commented 7 years ago

Expected behavior

terminus wp mysite.live search-replace http://mysite.com https://mysite.com

should replace all instances of http://mysite.com with https://mysite.com

Actual behavior

Zero replacements, even when I know via View Source that some http:// URLs still exist.

I also get a possibly truncated message (error?) stating:

tput: No value for $TERM and no -T specified

and a search for what this means yielded other github issue posts related to completely different commands. Not sure what to make of this for my particular command, but there was one prior search-replace command I ran where successful replacement happened and I still got this error, so maybe it's nothing.

I just need to figure out why the http:// to https:// string replacement failed to replace anything.

Steps to reproduce the behavior

Run the command

terminus wp mysite.live search-replace http://mysite.com https://mysite.com

changing out "mysite" with a real site name.

 ------------------------- ------------------------------------------------
  PHP binary                /usr/bin/php5
  PHP version               5.5.9-1ubuntu4.21
  php.ini used              /etc/php5/cli/php.ini
  Terminus project config
  Terminus root dir         /home/rwatson/vendor/pantheon-systems/terminus
  Terminus version          1.2.1
  Operating system          #1 PREEMPT Thu Aug 1 17:06:05 CST 2013
 ------------------------- ------------------------------------------------
TeslaDethray commented 7 years ago

@intechrahealth I cannot duplicate this issue.

tesladethray@Tima:~ $ t wp tesladethray.dev search-replace thee the
tput: No value for $TERM and no -T specified
+------------------+-----------------------+--------------+------+
| Table            | Column                | Replacements | Type |
+------------------+-----------------------+--------------+------+
| wp_commentmeta   | meta_key              | 0            | SQL  |
| wp_commentmeta   | meta_value            | 0            | SQL  |
| wp_comments      | comment_author        | 0            | SQL  |
| wp_comments      | comment_author_email  | 0            | SQL  |
| wp_comments      | comment_author_url    | 0            | SQL  |
| wp_comments      | comment_author_IP     | 0            | SQL  |
| wp_comments      | comment_content       | 0            | SQL  |
| wp_comments      | comment_approved      | 0            | SQL  |
| wp_comments      | comment_agent         | 0            | SQL  |
| wp_comments      | comment_type          | 0            | SQL  |
| wp_links         | link_url              | 0            | SQL  |
| wp_links         | link_name             | 0            | SQL  |
| wp_links         | link_image            | 0            | SQL  |
| wp_links         | link_target           | 0            | SQL  |
| wp_links         | link_description      | 0            | SQL  |
| wp_links         | link_visible          | 0            | SQL  |
| wp_links         | link_rel              | 0            | SQL  |
| wp_links         | link_notes            | 0            | SQL  |
| wp_links         | link_rss              | 0            | SQL  |
| wp_options       | option_name           | 14           | SQL  |
| wp_options       | option_value          | 8            | PHP  |
| wp_options       | autoload              | 0            | SQL  |
| wp_postmeta      | meta_key              | 0            | SQL  |
| wp_postmeta      | meta_value            | 0            | PHP  |
| wp_posts         | post_content          | 12           | SQL  |
| wp_posts         | post_title            | 6            | SQL  |
| wp_posts         | post_excerpt          | 0            | SQL  |
| wp_posts         | post_status           | 0            | SQL  |
| wp_posts         | comment_status        | 0            | SQL  |
| wp_posts         | ping_status           | 0            | SQL  |
| wp_posts         | post_password         | 0            | SQL  |
| wp_posts         | post_name             | 1            | SQL  |
| wp_posts         | to_ping               | 0            | SQL  |
| wp_posts         | pinged                | 0            | SQL  |
| wp_posts         | post_content_filtered | 0            | SQL  |
| wp_posts         | guid                  | 21           | SQL  |
| wp_posts         | post_type             | 0            | SQL  |
| wp_posts         | post_mime_type        | 0            | SQL  |
| wp_term_taxonomy | taxonomy              | 0            | SQL  |
| wp_term_taxonomy | description           | 0            | SQL  |
| wp_termmeta      | meta_key              | 0            | SQL  |
| wp_termmeta      | meta_value            | 0            | SQL  |
| wp_terms         | name                  | 0            | SQL  |
| wp_terms         | slug                  | 0            | SQL  |
| wp_usermeta      | meta_key              | 0            | SQL  |
| wp_usermeta      | meta_value            | 0            | PHP  |
| wp_users         | user_login            | 0            | SQL  |
| wp_users         | user_nicename         | 0            | SQL  |
| wp_users         | user_email            | 1            | SQL  |
| wp_users         | user_url              | 0            | SQL  |
| wp_users         | user_activation_key   | 0            | SQL  |
| wp_users         | display_name          | 0            | SQL  |
+------------------+-----------------------+--------------+------+
Success: Made 63 replacements.
 [notice] Command: tesladethray.dev -- wp search-replace the thee [Exit: 0]

What is the result when you attempt to search-replace on a dev or multidev environment using a ubiquitous string (like "the")?

blueprintmrk commented 6 years ago

I have had the same thing happen as shown above and now I am getting this

macosx$terminus wp site.live -- search-replace 'http://www.link.tld' 'https://www.link.tld' --skip-columns=guid Error: Error establishing a database connection. This either means that the username and password information in your wp-config.php file is incorrect or we can not contact the database server at database_host. This could mean your host's database server is down. `

`

blueprintmrk commented 6 years ago
Terminus WP-CLI Silent FailureThe following silent failure occurs when executing terminus remote:wp commands on environments that use redirect logic without checking to see if WordPress is running via the command line:

[notice] Command: <site>.<env> — ‘wp <command>’ [Exit: 0]
Redirects kill the PHP process before WP-CLI is executed. You can resolve this error by adding php_sapi_name() != “cli” as a conditional statement to all redirect logic within wp-config.php:
// Require HTTPS, www.
if (isset($_ENV[‘PANTHEON_ENVIRONMENT‘]) &&
($_ENV[‘PANTHEON_ENVIRONMENT‘] === ‘live’) &&
// Check if Drupal or WordPress is running via command line
(php_sapi_name() != “cli”)) {
if ($_SERVER[‘HTTP_HOST‘] != ‘www.yoursite.com’ ||
!isset($_SERVER[‘HTTP_USER_AGENT_HTTPS‘]) ||
$_SERVER[‘HTTP_USER_AGENT_HTTPS‘] != ‘ON’ ) {
header(‘HTTP/1.0 301 Moved Permanently’);
header(‘Location: https://www.yoursite.com’. $_SERVER[‘REQUEST_URI‘]);
exit();
}“https://www.yoursite.com”:http://www