tohokuaikiのチラシの裏

技術的ネタとか。

WordPressでテーマのcommon.cssがロードされてなくて焦った件

WordPressをバージョンアップしたらCSSが崩れた。

ん~~~~、ってHTMLをdiffして見てみたら

Before

<link rel='stylesheet' id='common-css'  href='/wp-content/themes/xxx/css/common.css' type='text/css' media='all' />

After

<link rel='stylesheet' id='common-css'  href='/wp-admin/css/common.min.css' type='text/css' media='all' />

ってなってた。

なんで管理画面のCSSなんかがロードされてるんじゃ。。

原因を探ってみる

とりあえず検索する。 こんなのがあった。 its-office.jp

んー、コアがCSSのロードを上書きしたっポイ。どっかなと探すと、、、

wp-includes/script-loader.php

ここで、

<?php
    // Admin CSS
    $styles->add( 'common',              "/wp-admin/css/common$suffix.css" );

ってされてた。

これによりテーマ内の function.php にて

<?php
wp_enqueue_style( 'common', get_template_directory_uri().'/css/common.css' );

してたのがダメになっちゃったんだね。

原因を探ってみる2

しつこい僕はこの互換性を破壊してそうなコードを誰がコミットしたのか調べてみた。

このコミット。 CSS: Stop using `wp-admin.min.css` and instead queue the individual s… · WordPress/WordPress@987ce83 · GitHub

まぁ、他のedit, aboutなんかをみてると、wp_enqueue_styleするのには自分のオレオレPrefixでも付けておけって感じなのかな。

影響を受けたバージョンも調べてみた

このコードを混入採用したのはどのバージョンからかっていうと・・・

WordPress Versions « WordPress Codex

によると4.4.2からってことみたい。

・・・・随分とWordPressをUpdateするのをスルーしてきたのがばれてしまうではないか・・・。

Google Chromeの新規タブに現れる「トップアクセス」みたいなサイトのサムネイルに不思議な画像

Google Chromeの新規タブに「よく行くサイト」みたいなのがあるじゃないですか。

あそこに見覚えのないものが・・・。

f:id:tohokuaiki:20160614093513p:plain

いや、サイト自体はLive Dowango Readerで、別に変じゃないんだけどなんだろうこの右側の画像は・・・。 この選択中のフィードに行ってもそれらしき画像は無いし・・・。

ということで、ちょっと調べたらこの画像はVirtualBoxの仮想ハードディスク追加ウィザードの画像っぽい。

手元のVirtualBoxで確認してみる。 なるほど、これか。

f:id:tohokuaiki:20160614093701p:plain

といっても、このウィザードだとちょっと違うなー。他のPCで使ったChromeのサムネイル共有されたのかな?

Vaio(Windows8.1)と秀Capsは同時に使ってはいけない(のかもしれない)

秀Capsとは

言わずと知れた超有名エディタ秀丸の作者が作ったキーボード関連の便利ウェア。

秀まるおのホームページ(サイトー企画)−秀Caps

自分は、アンダースコア「_」をシフトキー無しで入力したくてずっとAltIMEを使っていたのですが、Windows8ではどうしても動かずAltIMEの作者もお亡くなりになったということで諦めていました。

秀Capsはその機能があるのでインストールしてみました。

・・・・がトラブル発生

秀Capsは秀丸の手厚いサポートを持つ作者の作ということで安心して使えるな…と思っていたのですが。 インストール直後からWi-Fiに異常が・・・。Wi-Fiが切断される、しばらくすると接続できるがVPNにつながらない。。。Wi-Fiに接続できたと思ったら「制限あり」になる。。。。というトラブルが続発。

実は、1年前にも同じトラブルが起き、とにかくどうしようもなかった。 Wi-Fiが切れるだけでなく、Wi-Fiバイスまでデバイスマネージャに表示されなくなったりで、Windows8を再インストールしてもダメ。ハードウェア的トラブルと思いSONYVaioを送り返したりもした(結果異常なし)。

その時、秀Capsがあやしいなぁ。。。と思っていたので、再度工場出荷状態にした後は秀Capsをインストールせずに使っていた。

で、1年ぶりに秀Capsをインストール

すると、インストールした直後にWi-Fiが切れる。再接続しても「制限あり」になる。。。。。Wi-Fiつながったと思ってVPNに接続するとだめ。。。。ああああ。あの悪夢が。。。

すぐにアンインストール。だけど、どうもファイルが消せない。ExplorerにDLLが読み込まれている模様。再起動して再度削除。快適になった。

秀Capsが全面的に駄目なわけではなく、おそらくVaioに入っているソフトとの相性が悪い模様

VaioにはVaioCareを筆頭にいろいろとソフトが入っているんだけど、これがまたトラブルの元なんじゃないか疑惑がちらほら。秀Capsは多くのユーザーもいるだろうし、その方々が特に問題ないというのであればおそらくソフトとのバッティングだろう。

Symfony1.4の色々とメモ

自分用メモです。

既に存在するテーブルに対してDoctrineを使う

既存テーブルに迷惑を掛けないようにする。

config/doctrine/schema.yml

にテーブル定義をyamlで書く。検索できればいいからとりあえずこんな感じで。

Member:
  columns:
    id:          { type: integer,     notnull: true, primary: true, autoincrement: true }
    name:         { type: string(255), notnull: true }
    email:        { type: string(255), notnull: true }

その次にFindする。

Controller内で

<?php
$member = Doctrine::getTable('Member')->findOneByName($name);

とかかしてやる。

テンプレートにJSONを渡したい

Controllerで

action.class.php
<?php
$this->sample[] = array(
        'mid' => $mid,
        'point' => $point,
        'name' => $member_name,
    );

とかして与えた変数をテンプレート側でJSON展開したい場合。

Templateで

indexSuccess.php
<script>
var csvuploadAllData = <?=json_encode($sf_data->get('sample')->getRawValue());?>
</script>

View.xmlをモジュール単位で効かせる。

apps/(app_name)/modules/(module_name)/config/view.yml を作成して、テンプレートごとにレイアウトの有無を切り替えたり。

(view.yml)
default:
  has_layout:     true
  layout:         my_admin

indexSuccess:
  has_layout:     false

Configを使って設定値をアレしたい。

設定

Configを設定できるのは2か所

config/app.yml
apps/*****/config/app.yml

moduleの下に配置できるかと思ったけどできない。

all:
  foo:
    bar: 

取得

上記の場合、

sfConfig::get('app_foo_bar')

というようにする。

深さは2段階で調整すること。たとえば上記のymlの場合

sfConfig::get('app_foo')

ではNULLが返ってくる。

milkodeのWindows8へのインストールでハマっている件

コード検索をfind&grepでやらなくても済むmilkodeというソフトがあります。

Rubyで書かれたWEBアプリなのでgemで簡単インストール。・・・・なのですが、ハマってます。以前インストールした際はそうでもなかったのですが、2年ぶりくらいにインストールしたらハマりました。

Rubyのインストール

FAQによると推奨バージョンがruby 1.9.3p392/2.0.0p0ということでRubyInstallerから1.9.3をインストール。Powershellなどで使えるようにRubyへのパスを環境変数PATHに追加。

PS C:\Users\Takashi> ruby -v
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]

ついでに Devkitもインストールしておく。

gemでmilkodeのインストール

gemで簡単にインストールする。document関連のエラーが出るのが面倒なので-no-docをつける。たくさんの依存パッケージと共にインストールされる。

PS C:\Users\Takashi> gem install -no-doc milkode
Successfully installed milkode-1.8.8
1 gem installed

だけど、milkコマンドでエラーが出る。

PS C:\Users\Takashi> milk
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- groonga.so (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/groonga.rb:46:in `rescue in <top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/groonga.rb:42:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/database/groonga_database.rb:9:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/cdstk/cdstk.rb:24:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/cli.rb:4:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/bin/milk:7:in `<top (required)>'
        from C:/Ruby193/bin/milk:23:in `load'
        from C:/Ruby193/bin/milk:23:in `<main>'

groonga.soができてないということで怒られる。

んー、っということでcygwinで検索してみる。

Takashi@JUNOE-VAIOPRO13 ~
$ cd /cygdrive/c/Ruby193/lib
$ find . -name "groonga.so"|xargs ls -lh
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.1/groonga.so
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.2/groonga.so
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.3/groonga.so

なんかgroonga.soが既にあるような気がする。。。

rroonga単体でインストールしてみる。

PS C:\Users\Takashi> gem install rroonga
Successfully installed rroonga-6.0.0-x86-mingw32
1 gem installed

インストールできたっぽいが、milkコマンド実行してもダメ。前と同じエラー。

devkitの説明ページを見てみると、gemインストール時にオプションが必要みたい。 ということで、--platform=rubyをつけてみる。前と様子が変わる。

PS C:\Users\Takashi> gem install rroonga --platform=ruby
Fetching: rroonga-6.0.0.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rroonga:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb
checking for GCC... yes
checking for Win32 OS... yes
downloading http://packages.groonga.org/windows/groonga/groonga-6.0.0-x86.zip... done
extracting... done
installing... done
removing binary archive... done
checking for groonga version (>= 6.0.0)... yes
checking for -Wl,-rpath is available... yes
checking for HAVE_RUBY_ST_H in ruby.h... yes
checking for rb_errinfo() in ruby.h... yes
checking for rb_sym2str() in ruby.h... no
checking for rb_to_symbol() in ruby.h... no
checking for rb_ary_new_from_args() in ruby.h... no
checking for rb_ary_new_from_values() in ruby.h... no
checking for enum ruby_value_type in ruby.h... yes
checking for --enable-debug-log option... no
checking for --enable-debug-build option... no
checking for --enable-untyped-data-warning option... no
creating Makefile

make
compiling rb-grn-accessor.c
compiling rb-grn-array-cursor.c
compiling rb-grn-array.c
compiling rb-grn-column.c
rb-grn-column.c: In function 'rb_grn_column_find_indexes':
rb-grn-column.c:769:5: warning: implicit declaration of function 'rb_ary_new_capa'
compiling rb-grn-config.c
compiling rb-grn-context.c
compiling rb-grn-database.c
compiling rb-grn-double-array-trie-cursor.c
compiling rb-grn-double-array-trie.c
compiling rb-grn-encoding-support.c
compiling rb-grn-encoding.c
compiling rb-grn-equal-operator.c
compiling rb-grn-exception.c
compiling rb-grn-expression-builder.c
compiling rb-grn-expression.c
compiling rb-grn-fix-size-column.c
compiling rb-grn-flushable.c
compiling rb-grn-geo-point.c
compiling rb-grn-greater-equal-operator.c
compiling rb-grn-greater-operator.c
compiling rb-grn-hash-cursor.c
compiling rb-grn-hash.c
compiling rb-grn-index-column.c
compiling rb-grn-index-cursor.c
compiling rb-grn-index.c
compiling rb-grn-less-equal-operator.c
compiling rb-grn-less-operator.c
compiling rb-grn-logger.c
compiling rb-grn-match-operator.c
compiling rb-grn-normalizer.c
compiling rb-grn-not-equal-operator.c
compiling rb-grn-object.c
rb-grn-object.c: In function 'rb_grn_object_key_accessor_p':
rb-grn-object.c:1707:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1708:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_accessor_p':
rb-grn-object.c:1671:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1672:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_scorer_procedure_p':
rb-grn-object.c:1645:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1646:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_selector_only_procedure_p':
rb-grn-object.c:1619:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1620:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_selector_procedure_p':
rb-grn-object.c:1593:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1594:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_function_procedure_p':
rb-grn-object.c:1567:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1568:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_procedure_p':
rb-grn-object.c:1541:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1542:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_table_p':
rb-grn-object.c:1516:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1517:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_builtin_p':
rb-grn-object.c:1491:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1492:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_unlink':
rb-grn-object.c:626:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:627:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_close':
rb-grn-object.c:585:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:585:14: note: 'object' was declared here
rb-grn-object.c:586:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:586:14: note: 'context' was declared here
rb-grn-object.c: In function 'rb_grn_object_close_raw':
rb-grn-object.c:585:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:586:14: warning: 'context' may be used uninitialized in this function
compiling rb-grn-operator.c
compiling rb-grn-patricia-trie-cursor.c
compiling rb-grn-patricia-trie.c
compiling rb-grn-plugin.c
compiling rb-grn-posting.c
compiling rb-grn-prefix-operator.c
compiling rb-grn-procedure-type.c
compiling rb-grn-procedure.c
compiling rb-grn-query-logger.c
compiling rb-grn-record.c
compiling rb-grn-regexp-operator.c
compiling rb-grn-snippet.c
compiling rb-grn-table-cursor-key-support.c
compiling rb-grn-table-cursor.c
compiling rb-grn-table-key-support.c
compiling rb-grn-table.c
compiling rb-grn-thread.c
compiling rb-grn-type.c
compiling rb-grn-utils.c
compiling rb-grn-variable-size-column.c
compiling rb-grn-variable.c
compiling rb-grn-windows-event-logger.c
compiling rb-groonga.c
rb-groonga.c: In function 'rb_grn_s_get_error_message':
rb-groonga.c:49:9: warning: implicit declaration of function 'rb_enc_str_new_cstr'
linking shared-object groonga.so
Creating library file: libruby-groonga.arb-grn-column.o: In function `rb_grn_column_find_indexes':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\rroonga-6.0.0\ext\groonga/rb-grn-column.c:769: undefined reference to `rb_ary_new_capa'rb-groonga.o: In function `rb_grn_s_get_error_message':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\rroonga-6.0.0\ext\groonga/rb-groonga.c:49: undefined reference to `rb_enc_str_new_cstr'collect2: ld returned 1 exit status
make: *** [groonga.so] Error 1


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0/ext/groonga/gem_make.out

んー、groongaのコンパイルに失敗しているくさい。。。

groongaは単体でインストールできるので、Windowsインストーラをダウンロードしてインストールしてみる。こんなん普通に考えてパス通らないんじゃないかと思うんだけど、果たしてその通り何も変わらなかった。

というところでハマり。

対応策

Twitterで教えてもらった。

Ruby2.3にしたら問題なくgemでインストール完了。 なんて楽なんだ・・・・。@ktouさんありがとうございます。