致命错误:wp-db.php中允许的内存大小为268435456字节(尝试分配7864320字节)

时间:2017-05-03 11:39:21

标签: php wordpress fatal-error

每次尝试更新信息中心内的菜单时,我都收到以下错误:

  

致命错误:允许的内存大小为268435456字节(已尝试   在中分配7864320个字节)   /var/sites/p/[sitename].com/public_html/wp-includes/wp-db.php   在1369行

关闭以前的建议,我已经逐个停用所有插件,看看其中一个插件是否导致错误,尽管尽管停用所有插件仍然存在错误。

进入wp-db.php到第1369行,这就是它的内容:

$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );

要扩展,这是1342到1407行的内容:

 * Print SQL/DB error.
 *
 * @since 0.71
 * @global array $EZSQL_ERROR Stores error information of query and error string
 *
 * @param string $str The error to display
 * @return false|void False if the showing of errors is disabled.
 */
public function print_error( $str = '' ) {
    global $EZSQL_ERROR;

    if ( !$str ) {
        if ( $this->use_mysqli ) {
            $str = mysqli_error( $this->dbh );
        } else {
            $str = mysql_error( $this->dbh );
        }
    }
    $EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str );

    if ( $this->suppress_errors )
        return false;

    wp_load_translations_early();

    if ( $caller = $this->get_caller() ) {
        /* translators: 1: Database error message, 2: SQL query, 3: Name of the calling function */
        $error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
    } else {
        /* translators: 1: Database error message, 2: SQL query */
        $error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
    }

    error_log( $error_str );

    // Are we showing errors?
    if ( ! $this->show_errors )
        return false;

    // If there is an error then take note of it
    if ( is_multisite() ) {
        $msg = sprintf(
            "%s [%s]\n%s\n",
            __( 'WordPress database error:' ),
            $str,
            $this->last_query
        );

        if ( defined( 'ERRORLOGFILE' ) ) {
            error_log( $msg, 3, ERRORLOGFILE );
        }
        if ( defined( 'DIEONDBERROR' ) ) {
            wp_die( $msg );
        }
    } else {
        $str   = htmlspecialchars( $str, ENT_QUOTES );
        $query = htmlspecialchars( $this->last_query, ENT_QUOTES );

        printf(
            '<div id="error"><p class="wpdberror"><strong>%s</strong> [%s]<br /><code>%s</code></p></div>',
            __( 'WordPress database error:' ),
            $str,
            $query
        );
    }
}

等待进一步的建议。

1 个答案:

答案 0 :(得分:0)

通过用户Ewout找到here的建议,我进入了wp-config.php并编辑了

  

定义(&#39; WP_MEMORY_LIMIT&#39;,&#39; 96M&#39;);

更高的数字。当我过去尝试提高它时,最初设置为256。这还不够,所以我选择了一个数字10000,这解决了这个问题。我希望通过将其提升到这样一个数字来解决任何未来的问题,尽管它确实解决了这个问题。我希望这可以帮助其他新手收到相同的错误信息。