-
作者帖子
-
之前看到 weixiaoduo 有教程説 Wordpress 和 Discuz 的會員同步插件,但是目前這個插件已經不支持 Php 7 了,並且密碼修改也不能同步,不知道 xiaoduo 是否有付費的插件呢?或者像這樣插件修改如何收費呢?
不知道你找到的是什麼版本的,如果是最初原作者發佈的那個同步插件的話,已經廢了,
不過我們之前有預留 WordPress 與 Discuz 整合這方面的解決方案,今天我們在處理另一個項目,明天抽空再貼上詳細的説明。
好的,我使用的 https://devwp.bpteach.com/wp-admin/plugin-install.php?tab=plugin-information&plugin=ucenter-integration ,之前又可以正常使用一段時間,也看過你們的教程,但是現在是無法使用了。
1 、 UCENTER 客户端不兼容 PHP7 導致 UCENTER 通信失敗
wordpress 的 ucenter 插件或者 discuz 如果使用 php7 可能會導致通訊失敗,原因是 ucenter 的客户端比較久遠,沒有兼容 php7,其中的
echo $uc_note->$get['action']($get, $post);
而 php5 到 php7 有一個 breaking change 和類方法動態調用有關
https://php.net/manual/zh/migration70.incompatible.php
php5 和 php7 對這段代碼的解釋順序是不同的,所以導致了 dz 在 php7 下這裏運行出錯,修改也很簡單,參照樣例,這裏修改為
echo $uc_note->{$get[『action』]}($get, $post);
就可以讓 php7 用無歧義的方式解析成 php5 的結果,於是就能通信成功了
2 、 wordpress 與 discuz 整合, ucenter-integration 插件無法同步登陸解決
discuz 與 wordpress 整合只能通過 ucenter-integration 插件,也只有這一個上古插件,安裝,設置一切順利,但是
説到但是總是讓人蛋疼,折騰了好幾天,必須得鋪墊鋪墊
但是隻可以 wordpress 登陸,同步登陸到 discuz,而 discuz 登陸註銷,卻無法同步到 wordpress
找了好多資料,反反覆覆就那麼兩個解決方案,都是改某處代碼,但是沒什麼鳥用,自己折騰半天,終於找到原因,解決辦法:
原因是因為 discuz 下面 uc_client\client.php 的第 379 行
function uc_user_synlogout() { if(@include UC_ROOT.』./data/cache/apps.php』) { if(count($_CACHE[『apps』]) > 1) { $return = uc_api_post(『user』, 『synlogout』, array()); } else { $return = 」; } } return $return; }
if(count($_CACHE[『apps』]) > 1) {這個判斷出錯,$_CACHE[『apps』] 數組應該是 2 或者更多的,但是這裏是 1,所以無論 discuz 如何登陸退出,都不會向 ucenter 發送同步通知,自然 wordpress 也就無法收到,無法實現同步了
打開這個配置文件,確實,只有一個數組,原來,是因為安裝了獨立的 ucenter,dz 下面的 cache/apps.php 沒有更新,可能是 ucenter 清除緩存出了問題,或者其他原因。
解決方法很簡單,將 ucenter-integration 插件下面的/data/cache/apps.php 文件複製出來,覆蓋到 dz 的 uc_client/data/cache/apps.php 下面就 OK 了
謝謝,不過這兩篇博客其實我之前又搜索到,也嘗試過了。首先,「echo $uc_note->$get[‘action’]($get, $post);」,插件文件不存在這個代碼,只有在/wp-content/plugins/ucenter-integration/api/uc.php 有如下:
58: if ( in_array( $get[‘action’], array( ‘test’, ‘synlogin’, ‘synlogout’, ‘getcreditsettings’, ‘updatecreditsettings’ ) ) ) {
61: exit( $uc_note->$get[‘action’]($get, $post) );我將其就修改為:
58: if ( in_array( $get[‘action’], array( ‘test’, ‘synlogin’, ‘synlogout’, ‘getcreditsettings’, ‘updatecreditsettings’ ) ) ) {
61: exit( $uc_note->{$get[‘action’]}($get, $post) );但是 DZ 還是顯示通信不成功,如果是 PHP 56 版本,未修改任何代碼,倒是可以正常使用。
另外,切換到 PHP7 以後,我也打開了 WP debug log,發現如下:
PHP Notice: Constant UCENTER_INTEGRATION_SETTING_NAME already defined in /wp-content/plugins/ucenter-integration/ucenter.php on line 18
Strict Standards: Redefining already defined constructor for class Ucenter_Integration in /wp-content/plugins/ucenter-integration/ucenter.php on line 50
只是我不熟悉 PHP,不太懂這個是否與無法通信相關。
又測試了下我們自己預留的方案,在 discuz x3.4 和 WordPress 4.9.4 開啓 ssl 訪問的情況下,依舊是無效的,也就是説就現在而言,這個插件是報廢了。
這些代碼都缺乏維護,如果你的確非常需要的話,可以找其他人進行定製新的插件,我們已經在開始慢慢剔除 discuz 業務,所以不接這類的修改定製。
嗯,我這邊測試 HTTPs 也是一樣。好的,感謝!
-
作者帖子
- 哎呀,回覆話題必需登錄。