即使分配了大量内存,内存也会耗尽

时间:2018-04-02 13:42:39

标签: php wordpress

我意识到有很多类似的线程,我检查了所有这些。我试图在php.iniwp-config.phpwp-settings.php中增加内存限制,但没有任何帮助。

当前错误是:

  

致命错误:第2516行/home/xxx/public_html/wp-includes/wp-db.php中允许的内存大小为67108864字节(试图分配72个字节)

我在php.ini中的限制是

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 3600
max_input_time = 3600
max_input_vars = 1000
memory_limit = 8192M
post_max_size = 256M

我不知道该再增加什么。

编辑:phpinfo()显示此

enter image description here

修改:wp-db.php

错误在这里:

 else {
            // ...column name-keyed row arrays
            $new_array[] = get_object_vars( $row );
 }

这是完整的功能(对不起长代码)

    /**
 * Retrieve an entire SQL result set from the database (i.e., many rows)
 *
 * Executes a SQL query and returns the entire SQL result.
 *
 * @since 0.71
 *
 * @param string $query  SQL query.
 * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants.
 *                       With one of the first three, return an array of rows indexed from 0 by SQL result row number.
 *                       Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively.
 *                       With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value.
 *                       Duplicate keys are discarded.
 * @return array|object|null Database query results
 */
public function get_results( $query = null, $output = OBJECT ) {
    $this->func_call = "\$db->get_results(\"$query\", $output)";

    if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
        $this->check_current_query = false;
    }

    if ( $query ) {
        $this->query( $query );
    } else {
        return null;
    }

    $new_array = array();
    if ( $output == OBJECT ) {
        // Return an integer-keyed array of row objects
        return $this->last_result;
    } elseif ( $output == OBJECT_K ) {
        // Return an array of row objects with keys from column 1
        // (Duplicates are discarded)
        foreach ( $this->last_result as $row ) {
            $var_by_ref = get_object_vars( $row );
            $key = array_shift( $var_by_ref );
            if ( ! isset( $new_array[ $key ] ) )
                $new_array[ $key ] = $row;
        }
        return $new_array;
    } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
        // Return an integer-keyed array of...
        if ( $this->last_result ) {
            foreach ( (array) $this->last_result as $row ) {
                if ( $output == ARRAY_N ) {
                    // ...integer-keyed row arrays
                    $new_array[] = array_values( get_object_vars( $row ) );
                } else {
                    // ...column name-keyed row arrays
                    $new_array[] = get_object_vars( $row );
                }
            }
        }
        return $new_array;
    } elseif ( strtoupper( $output ) === OBJECT ) {
        // Back compat for OBJECT being previously case insensitive.
        return $this->last_result;
    }
    return null;
}

0 个答案:

没有答案
相关问题