• Antonio Garcia

    (@agarciasantisteban)


    I apologice if this message is wrong in any way, this is my first comment in WordPress forum.

    In a page having a 33KB content and 17 revisions, when the “Browse” revisions link is clicked the next error message appears:

    Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 268435464 bytes)
    in /usr/local/www/global/htdocs/wp/wp-includes/class-wp-text-diff-renderer-table.php on line 419

    It was confirmed by many logs than there aren’t errors in plugins or similar.
    For render a 33KB page revision, a 512MB php.ini memory_limit could be not enought.

    The problem is next class-wp-text-diff-renderer-table.php code

    foreach ( $orig_rows_copy as $orig_row ) {
    	$final_pos = array_search( $orig_matches[ $orig_row ], $final_rows, true );
    	$orig_pos  = (int) array_search( $orig_row, $orig_rows, true );
    
    	if ( false === $final_pos ) { // This orig is paired with a blank final.
    		array_splice( $final_rows, $orig_pos, 0, -1 );
    	} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
    		$diff_array = range( -1, $final_pos - $orig_pos );
    		array_splice( $final_rows, $orig_pos, 0, $diff_array );   // line 419
    	} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
    		$diff_array = range( -1, $orig_pos - $final_pos );
    		array_splice( $orig_rows, $orig_pos, 0, $diff_array );
    	}
    }

    The array_splice is using so much memory than creates an error, and I can’t find how to modify this from functions.php using hooks, filters, or a similar accesible way (changing this core file the problem was solved… but change core files is not a good idea).

    My 2 questions:
    1- Is there any way of change this from functions.php using hooks or so?.
    If not, how about to add to WordPress a way for change this?. A hook, filter or similar.

    2- Could be modified the revisions render code for use less memory?.
    More than 512 MB memory for render a 33KB content revision isn’t too much memory?.

Viewing 1 replies (of 1 total)
  • Anonymous User 14808221

    (@anonymized-14808221)

    Allowed memory size exhaustion errors are almost never due to the function or file they actually point to in their error stack and almost always to some process that eats up all memory prior to the code that then fails, and is filed as the “culprit” in the error stack.

    What you want to do is test this first without any other plugin active, and with a WordPress default theme, not using any custom code.

    If then the error still would happen, it would mean there is indeed some problem with WordPress Core handling of reviews, since 512MB should be largely enough for a (standard) WordPress install.

    However I suspect, as soon plugins (and eventually theme) are taken out of the equation, the problem will be gone

    If not, We then would need to analyse steps of replication and eventually, maybe report this to Trac for fixing.

    However if my math is correct, your entire revisions are barely 15MB all together, so 512MB should be far enough to handle this. I am not good at math, so I might be wrong and perhaps you did all the “disable plugins” testing already?

    Please let me know 🙂

    • This reply was modified 5 years ago by Anonymous User 14808221.
Viewing 1 replies (of 1 total)

The topic ‘Revision page render: allowed memory exhausted.’ is closed to new replies.