Skip to content

Conversation

@daithi-coombes
Copy link

forked from #278

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use $wpdb->tables( 'global' )?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect ;)

@daithi-coombes
Copy link
Author

@scribu I have tested this by changing a username and blog name, and checked that the text/varchar fields are used from each table. Think this PR maybe ready for a merge or the next state

@scribu
Copy link
Member

scribu commented May 30, 2013

The next step would be to make it mergea-ble into master again (I merged #473 recently).

  1. Update master:
git remote add upstream git://github.com/wp-cli/wp-cli.git
git checkout master
git pull -u upstream
  1. Re-apply changes to the branch (also has the benefit of cleaning up the history):
git checkout multisite-find-replace
git reset master
git commit -a
git push -f

@scribu
Copy link
Member

scribu commented May 30, 2013

Or, the more familiar route, merge master into the branch (and resolve conflicts).

@scribu
Copy link
Member

scribu commented May 30, 2013

You squashed all the commits into one, but the parent commit is still the old one. The latest HEAD in master is 5432c54

See https://github.com/wp-cli/wp-cli/network

@daithi-coombes
Copy link
Author

@scribu sorry, think I might have merged with master twice after you. Got numerous errors when trying to merge the pr with remote/master, hope its all working (sorry if i've given you extra headache there)

@scribu
Copy link
Member

scribu commented May 30, 2013

Just do this:

git reset remote/master
git ci -am "search-replace function modified to perform a search and replace through multisite specific tables"
git push -f

@daithi-coombes
Copy link
Author

typo:

git: 'ci' is not a git command.

@daithi-coombes
Copy link
Author

also from git reset remote/master

git reset remote/master
fatal: ambiguous argument 'remote/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

my config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/daithi-coombes/wp-cli.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "multisite-find-replace"]
        remote = origin
        merge = refs/heads/multisite-find-replace
[remote "upstream"]
        url = git://github.com/wp-cli/wp-cli.git
        fetch = +refs/heads/*:refs/remotes/upstream/*

@scribu
Copy link
Member

scribu commented May 30, 2013

Right, ci is a git alias of mine.

git fetch upstream
git reset upstream/master
git commit -am "search-replace function modified to perform a search and replace through multisite specific tables"
git push -f

@daithi-coombes
Copy link
Author

looking at the network chart not sure if that went through right?
https://github.com/wp-cli/wp-cli/network

@scribu
Copy link
Member

scribu commented May 30, 2013

It's good now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the fix here to ignore the first column?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it - just above fields is set to array( $primary_key, $col ), so the first column is null. But I worry about the update later on. It seems to me if null is passed for the $where argument, no updates will be made. I think the current strategy requires a primary key.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it. Two possible solutions:

a) skip tables which don't have a primary key column
b) for tables without a primary key column, assume they don't have serialized values and do a single UPDATE query

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of wp_signups, there is a field ('meta') that contains serialized data. Option a) seems safer to me. Maybe instead of zero column counts in the output for that table we could have an output row indicating the table was skipped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daithi-coombes This hasn't been resolved.

@scribu
Copy link
Member

scribu commented May 30, 2013

cc: @cyberhobo

@scribu
Copy link
Member

scribu commented Jun 3, 2013

Just to clear up any misunderstandings:

@daithi-coombes Do you think you'll have time to continue working on this? Let me know if anything is unclear.

@daithi-coombes
Copy link
Author

sure I have time. Will start on it imediately

@scribu
Copy link
Member

scribu commented Jun 4, 2013

Alright. Just shout when you think the code is ready for another review or if you get stuck.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just add this as a regular step to the "Given" part of the scenario:

Given a WP multisite install
And I run `wp blog --slug="foo" --title="foo" --email="foo@example.com"`
And ...

When I run `wp search-replace foo bar --multisite`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible because Behat doesn't care if a step is defined with $step->Given() or $step->Then().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove this unused step definition.

@scribu
Copy link
Member

scribu commented Jun 7, 2013

@scribu is this ready for merge? I'm not sure if my bdd is sufficient.

It will be ready for merge when all the inline comments are gone: https://github.com/wp-cli/wp-cli/pull/481/files

(they disappear once the line of code they reference is removed or changed)

@daithi-coombes
Copy link
Author

I have added wp_2_options:value to the feature check, and now tables with primary key are skipped and this is reported in the table printout.

One issue is that its failing the CI test (the 3rd ci test) but I can't recreate the failure on my machine

@scribu
Copy link
Member

scribu commented Jun 8, 2013

One issue is that its failing the CI test (the 3rd ci test) but I can't recreate the failure on my machine

Are you sure that you're running the tests against WP 3.4.2?

You just need to run:

rm -rf /tmp/wp-cli-test-core-download-cache/
wp core download --version=3.4.2 --path=/tmp/wp-cli-test-core-download-cache/

and then run the search-replace tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed... if a user's password hash contains the keyword being replaced then there will be login issues. Is there currently a blacklist of tables:cols?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! No blacklist, currently.

@daithi-coombes
Copy link
Author

ready for review,

if go-ahead, then i'm gonna:

git fetch upstream
git reset upstream/master
git commit -am "merge msg"
git push -f

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is redundant (you could get the same information by just looking at the code); explain the "why", not the "how".

@scribu
Copy link
Member

scribu commented Jun 8, 2013

It looks good.

The only minor complaint I have left is inconsistent use of whitespace. For example:

isset( $assoc_args['multisite']);

should be:

isset( $assoc_args['multisite'] );

I'll let you guess what the next one should be:

} else{

See http://make.wordpress.org/core/handbook/coding-standards/php/#space-usage

@daithi-coombes
Copy link
Author

done ;) Cheers for the tips, especially commenting the "why" and not "how", learn something new everyday

@scribu
Copy link
Member

scribu commented Jun 8, 2013

Alright; please combine all your commits into one again.

I'll merge soon.

@scribu
Copy link
Member

scribu commented Jun 8, 2013

Merged via #501.

Thanks for getting this off the ground, @daithi-coombes!

@scribu scribu closed this Jun 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants