2012-08-13 32 views
4

當我將PHP錯誤報告置於我的WordPress安裝程序中時,我不斷收到此錯誤。錯誤:只應通過wp-includes/post.php中的引用返回變量引用

Notice: Only variable references should be returned by reference in /Users/admin/Sites/wp-includes/post.php on line 3394

我有它與分類及其層級設置做的感覺。

一直試圖追查一下現在在我正在寫的插件

這些是WP Core中的實際代碼行,返回值位於excact行。

// Make sure the post type is hierarchical 
$hierarchical_post_types = get_post_types(array('hierarchical' => true)); 
if (!in_array($post_type, $hierarchical_post_types)) 
     return false; 

我會繼續調試它,直到我發現這個問題,但是任何輸入將是我沒有在我的插件就找到了問題的高度視寧度。

+1

也許你的插件調用了一個WP核心函數錯誤並導致了錯誤(有時候使用jQuery)。查看回溯,找出在WP核心功能之前調用的功能。你可以使用'debug_print_backtrace()'; http://www.php.net/manual/en/function.debug-print-backtrace.php – 2012-08-13 08:58:55

回答

6

return false; - 這不是一個變量
試着這麼做

if (!in_array($post_type, $hierarchical_post_types)) { 
     $rv = false; 
     return $rv; 
} 

(邊注:我不知道WordPress和/或你正在使用有一個MOD是幹什麼的,但也許/可能「通過引用返回」是a)首先是不必要的,並且b)來自php4實現的遺漏)

+0

不錯的工作。這實際上解決了這個問題。但它位於WP Core中,所以我會猜測要記錄一張票。奇怪,因爲它是拋出這個錯誤的默認的vanilla get_pages()函數(自V.1.5.0起)。也許是一個PHP 5.4的問題。 – Foxinni 2012-08-13 09:34:56

+0

它似乎只是從我的插件拋出通知錯誤,而不是如果它在主題中... – Foxinni 2012-08-13 10:03:58

+0

問題是在Trac中,將密切關注它。 http://core.trac.wordpress.org/ticket/20756#comment:2 – Foxinni 2012-08-13 10:29:35

相關問題