Do these two steps instead of reinstalling wpsnapshots

If global Composer scripts are not in your path, add them:

export PATH=~/.composer/vendor/bin:$PATH

If you are using VVV, add global Composer scripts to your path with this command:

export PATH=~/.config/composer/vendor/bin:$PATH
Advertisements

The Null Coalescing Operator is a thing now

You can do this:

$var = isset($_POST['var']) ? $_POST['var'] : 'other';
becomes: 
$var = $_POST['var'] ?? 'other';

I can’t wait to try it.

Maybe you need to install some submodules.

git submodule update --init --recursive

Trying to install scss-lint. It doesn’t work.

vagrant $ sudo gem install scss-lint
ERROR:  Error installing scss-lint:
	rake requires Ruby version >= 2.0.0.

Extra annoying because I have Ruby 2.4.x. There is a force option though.

vagrant $ sudo gem install scss-lint -f

That works.

It was a pain in…

It was a pain in the ass to get `sass` installed on my vagrant box. This helped.

https://github.com/Varying-Vagrant-Vagrants/VVV/issues/890

It was this command:

export PATH=”/var/lib/gems/1.9.1/gems/sass-3.4.22/bin:$PATH”

But I had to change the sass version to 3.5.

This was relevant too. https://stackoverflow.com/questions/20176410/how-to-resolve-you-need-to-have-ruby-and-sass-installed-and-in-your-path-for-th

Cherry Picking

Trying to push a new feature branch, you accidentally branch of staging instead of master. git cherry-pick can help in this case.

  
$ git checkout feature/paid-campaign-measurement

This branch has `develop` as its parent. It should have `master`.

  
$ git log --oneline
37ad159 Remove uneeded comment
f671fa7 Added logic for checking whether to insert code
cc746b3 Add static class for facebook tracking code
b04dc50 Merge branch 'fix/golden-state-warriors-logo'
37a0c7c Fixed warriors logo

This gets me a list of the last few commits. The first three are mine.

$ git status
On branch feature/paid-campaign-measurement
$ git checkout master
$ git pull origin master

I make sure I’m on the right branch.

I’m going to fix this with a cherry-pick. git rebase is another way to fix it – but I spent two hours thinking about the rebase this morning, and was too nervous to go through with it. cherry-pick, I know how to do.

git checkout -b feature/facebook-campaign-measurement

This creates a new branch with a pretty similar name.

git cherry-pick --help

Get my syntax, to be sure I know what I’m doing.

$ git cherry-pick cc746b3
[feature/facebook-campaign-measurement fae0a96] Add static class for facebook tracking code
 Date: Fri Jan 26 11:03:55 2018 -0800
 2 files changed, 42 insertions(+)
 create mode 100644 plugins/msgn/includes/MSGN/Analytics/Facebook.php
$ git cherry-pick f671fa7
[feature/facebook-campaign-measurement 4ad13a0] Added logic for checking whether to insert code
 Date: Fri Jan 26 12:12:28 2018 -0800
 2 files changed, 23 insertions(+), 1 deletion(-)
$ git cherry-pick 37ad159
[feature/facebook-campaign-measurement b705421] Remove uneeded comment
 Date: Fri Jan 26 13:57:44 2018 -0800
 1 file changed, 10 deletions(-)

I cherry-pick my three commits in the same order I made them.

$ git status
On branch feature/facebook-campaign-measurement
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	../../plugins/msgn/package-lock.json

nothing added to commit but untracked files present (use "git add" to track)
$ git push origin feature/facebook-campaign-measurement
Counting objects: 27, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (27/27), 3.14 KiB | 0 bytes/s, done.
Total 27 (delta 16), reused 0 (delta 0)
To git@git.beanstalkapp.com:/msgn.git
 * [new branch]      feature/facebook-campaign-measurement -> feature/facebook-campaign-measurement

Then I cancel the code review on my old branch and request code review on the new one.

Working with a WordPress site…

Working with a WordPress site where you have a lot of hardcoded image URLs, but the actual images aren’t in your repository.

One way to deal with the broken images is to use an nginx rule to rewrite the images url to a remote staging site.

Here’s my nginx configuration file, located at vagrant/www/{my-site}/provision/vvv-nginx.conf.tmpl:

server {
    listen       80;
    listen       443 ssl;
    server_name  {{DOMAINS_HERE}};
    root         {vvv_path_to_site}/public_html;

    error_log    {vvv_path_to_site}/log/error.log;
    access_log   {vvv_path_to_site}/log/access.log;

    set          $upstream {upstream};

    include      /etc/nginx/nginx-wp-common.conf;

	location ~* \.(gif|jpg|jpeg|png)$ {
		if ($uri ~ "^/wp-content/uploads/[^/]*/.*$"){
			set $rule_0 1$rule_0;
		}
		if ($rule_0 = "1"){
			rewrite ^/(.*)$ https://ecorner-staging.tcg.stanford.edu/$1 last;
		}
	}
}

Note that the .tmpl file is used rather than the .conf file, and that the `location` block is within the server block.

Sources:
https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/custom-public_html/
https://github.com/Varying-Vagrant-Vagrants/VVV/issues/244
https://css-tricks.com/develop-locally-use-images-production/