Skip to content

Instantly share code, notes, and snippets.

@htdat
Last active July 12, 2021 04:31
Show Gist options
  • Save htdat/06d77ea326d53cb1ae1e6b68c96aa0c3 to your computer and use it in GitHub Desktop.
Save htdat/06d77ea326d53cb1ae1e6b68c96aa0c3 to your computer and use it in GitHub Desktop.

Revisions

  1. htdat renamed this gist Jul 12, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. htdat revised this gist Jul 12, 2021. 1 changed file with 12 additions and 21 deletions.
    33 changes: 12 additions & 21 deletions trac-49089.php
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,15 @@
    <?php
    /**
    * Snippet to replicate this issue https://core.trac.wordpress.org/ticket/49089
    * Usage:
    * - Convert this file as a plugin, or much easier add this file under wp-content/mu-plugins
    * - Visit wp-admin/edit.php
    * - Try to edit a post with "Quick Edit" to trigger the ajax action
    * - Check PHP error log (debug.log)
    */
    class Trac_49089_WP_List_Table extends WP_List_Table {

    public function __construct() {

    parent::__construct(
    /*
    Plugin Name: Replicate core issue 49089
    Plugin URI: https://core.trac.wordpress.org/ticket/49089
    Description: Steps to replicate: (1) Visit wp-admin/edit.php, (2) Try to edit a post with "Quick Edit" to trigger the ajax action, (3) Check PHP error log (debug.log)
    Author: htdat
    Version: 0.1-dev
    */
    add_action(
    'wp_ajax_inline-save',
    function () {
    new WP_List_Table(
    array(
    'plural' => 'plural',
    'singular' => 'singular',
    @@ -20,16 +18,9 @@ public function __construct() {
    * The PHP error does not happen if `screen` value is different from NULL or ``
    * Removing the comment below will prevent the error from happening
    */
    // 'screen' => 'anything',
    // 'screen' => 'anything',
    )
    );
    }
    }

    add_action(
    'wp_ajax_inline-save',
    function () {
    new Trac_49089_WP_List_Table();
    },
    /**
    * Core calls this action with priority = 1, and since it's an AJAX request,
  3. htdat created this gist Jun 14, 2021.
    41 changes: 41 additions & 0 deletions trac-49089.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    <?php
    /**
    * Snippet to replicate this issue https://core.trac.wordpress.org/ticket/49089
    * Usage:
    * - Convert this file as a plugin, or much easier add this file under wp-content/mu-plugins
    * - Visit wp-admin/edit.php
    * - Try to edit a post with "Quick Edit" to trigger the ajax action
    * - Check PHP error log (debug.log)
    */
    class Trac_49089_WP_List_Table extends WP_List_Table {

    public function __construct() {

    parent::__construct(
    array(
    'plural' => 'plural',
    'singular' => 'singular',
    'ajax' => true,
    /**
    * The PHP error does not happen if `screen` value is different from NULL or ``
    * Removing the comment below will prevent the error from happening
    */
    // 'screen' => 'anything',
    )
    );
    }
    }

    add_action(
    'wp_ajax_inline-save',
    function () {
    new Trac_49089_WP_List_Table();
    },
    /**
    * Core calls this action with priority = 1, and since it's an AJAX request,
    * the whole process is terminated early before the added action here can be reached out
    *
    * @see https://github.com/WordPress/wordpress-develop/blob/132984c20f4a539dddeeaf7f9f65716854a89b55/src/wp-admin/admin-ajax.php#L163-L165
    */
    -1
    );