Title: Problems with Plugin &#8220;TablePress&#8221;
Last modified: December 23, 2022

---

# Problems with Plugin “TablePress”

 *  Resolved [reasonx](https://wordpress.org/support/users/reasonx/)
 * (@reasonx)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/)
 * Tested on:
    - WordPress 6.1.1
    - plugin load filter 4.0.12 (and older versions)
    - TablePress 2.0 (and older versions)
 * problem description:
 * you can not insert images into table cells because plugin load filter interferes
   in the ajax call. If you deactivate plugin load filter, it works fine.
 * Steps to reproduce:
    1. install Plugin “TablePress” by Author Tobias Bäthge
    2. install Plugin “plugin load filter”
    3. In admin menu click on “TablePress”
    4. Create a new table
    5. Right Click on a table cell and choose “Insert Image” or click on the “Insert
       Image” button below the table.
    6. The image does not get inserted throwing an PHP Error
 *     ```wp-block-code
       PHP Fatal error:  Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given
       ```
   
 * The problem is triggered in mu-plugins/plf-filter.php on line 1002
 *     ```wp-block-code
       $GLOBALS['wp']->query_posts();
       ```
   
 * which calls wp_basename() with $path as an argument which contains an array at
   this point, which is not right. It should be a string and not an array. It then
   calls urlencode() which throws the error.
 * If you print out the $_POST variable for the ajax request it contains something
   like that:
 *     ```wp-block-code
       Array
       (
           [nonce] => f8a54e0db5
           [attachment] => Array
               (
                   [id] => 769070
                   [post_content] => 
                   [post_excerpt] => 
                   [align] => right
                   [image-size] => full
               )
   
           [html] => <img src="" width="2400" height="1800" alt="" class="wp-image-769070 alignright size-full" />
           [post_id] => 0
           [action] => send-attachment-to-editor
       )
       ```
   
 * Since i cant hook into your plugin because it loads first as a mu-plugin I can
   ´t change this behavior.
 * My current workaround is:
 *     ```wp-block-code
       if ($_POST['action'] === 'send-attachment-to-editor') {
           return false;
       }
       ```
   
 * somewhere above line 1002 in mu-plugins/plf-filter.php
 * Thank you very much for your help.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [enomoto celtislab](https://wordpress.org/support/users/enomoto-celtislab/)
 * (@enomoto-celtislab)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/#post-16319635)
 * I tried adding TablePress 2.0 to the test environment, but the error you pointed
   out does not reproduce.
 * please check a few.
 * This problem is said to occur at line 1002 of mu-plugins/plf-filter.php, but 
   this seems to be the previous ver4.0.11. Does ver4.0.12 still cause an error?
 * Can you reproduce this by enabling only the Plugin load filter and TablePress
   plugins and disabling all other plugins?
 * It says that the urlencode() function is causing the error, but the plugin load
   filter plugin does not use the urlencode function directly.　It seems that the
   urlencode() function is used in several places in the TablePress plugin, so I
   think that it is necessary to deal with it as a fundamental problem
 *  Thread Starter [reasonx](https://wordpress.org/support/users/reasonx/)
 * (@reasonx)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/#post-16335319)
 * Hi,
 * thank you very much for your answer. I was already using version 4.0.12 of PLF.
   And the error also occours when switching off all plugins except tablepress &
   PLF.
 * After your answer I testet it again and I found out, that the error only occurs
   when using PHP 8.1. If I switch my local environment back to PHP 7.4 it works
   fine. That is because in PHP 7.4 PHP only throws a warning whereas in PHP 8.1
   PHP throws a fatal error. Did you also test with PHP 8.1? If not, you could try
   again to reproduce the error. You have to create a table and then insert an image
   to a table cell. The Ajax call should return an PHP Error when running PHP 8.1.
 * In the meantime tablepress got updated to version 2.0.2 so I installed that update.
   Unfortunately the problem still exists.
 * Maybe the stacktrace is helping:
 *     ```wp-block-code
       [error] FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given in /wp-includes/formatting.php:5525
   
       Stack trace:
   
       #0 /wp-includes/formatting.php(5525): urlencode()
       #1 /wp-includes/class-wp-query.php(2134): wp_basename()
       #2 /wp-includes/class-wp-query.php(3749): WP_Query->get_posts()
       #3 /wp-includes/class-wp.php(663): WP_Query->query()
       #4 /wp-content/mu-plugins/plf-filter.php(1020): WP->query_posts()
       #5 /wp-content/mu-plugins/plf-filter.php(298): Plf_filter::plf_filter()
       #6 /wp-includes/class-wp-hook.php(310): Plf_filter::active_plugins()
       #7 /wp-includes/plugin.php(205): WP_Hook->apply_filters()
       #8 /wp-includes/option" while reading response header from upstream, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", referrer: "/wp-admin/admin.php?page=tablepress&action=edit&table_id=609"
       ```
   
 * As I said my current workaround for this is to put this code
 *     ```wp-block-code
       if (!empty($_POST['action']) && $_POST['action'] === 'send-attachment-to-editor') {
           return false;
       }
       ```
   
 * into /mu-plugins/plf-filter.php before $GLOBALS[‘wp’]->query_posts();
 * Thank you very much for your help.
 *  Plugin Author [enomoto celtislab](https://wordpress.org/support/users/enomoto-celtislab/)
 * (@enomoto-celtislab)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/#post-16343755)
 * In my environment (PHP8.1.13). Couldn’t reproduce
 *     ```wp-block-code
       wp-core
   
       version: 6.1.1
       site_language: en_US
       user_language: en_US
       timezone: Asia/Tokyo
       permalink: /archives/%post_id%/%postname%/
       https_status: true
       multisite: false
       user_registration: 1
       blog_public: 0
       default_comment_status: open
       environment_type: production
       user_count: 5
       dotorg_communication: true
   
       wp-paths-sizes
   
       wordpress_path: /var/www/html/wordpress
       wordpress_size: 47.11 MB (49393293 bytes)
       uploads_path: /var/www/html/wordpress/wp-content/uploads
       uploads_size: 48.28 MB (50624588 bytes)
       themes_path: /var/www/html/wordpress/wp-content/themes
       themes_size: 8.31 MB (8718412 bytes)
       plugins_path: /var/www/html/wordpress/wp-content/plugins
       plugins_size: 1.52 MB (1596183 bytes)
       database_size: 11.64 MB (12206080 bytes)
       total_size: 116.86 MB (122538556 bytes)
   
       wp-active-theme
   
       name: Twenty Twenty-One (twentytwentyone)
       version: 1.7
       author: the WordPress team
       author_website: https://wordpress.org/
       parent_theme: none
       theme_features: core-block-patterns, widgets-block-editor, automatic-feed-links, title-tag, post-formats, post-thumbnails, menus, html5, custom-logo, customize-selective-refresh-widgets, wp-block-styles, align-wide, editor-styles, editor-style, editor-font-sizes, custom-background, editor-color-palette, editor-gradient-presets, responsive-embeds, custom-line-height, experimental-link-color, custom-spacing, custom-units, widgets
       theme_path: /var/www/html/wordpress/wp-content/themes/twentytwentyone
       auto_update: Disabled
   
   
       wp-mu-plugins (1)
   
       plugin load filter [plf-filter]: version: 4.0.12, author: enomoto@celtislab
   
       wp-plugins-active (3)
   
       localhost2host.docker.internal: version: 0.1.0, author: enomoto@celtislab, Auto-updates disabled
       plugin load filter: version: 4.0.12, author: enomoto@celtislab, Auto-updates disabled
       TablePress: version: 2.0.2, author: Tobias Bäthge, Auto-updates disabled
   
   
       wp-server
   
       server_architecture: Linux 5.10.102.1-microsoft-standard-WSL2 x86_64
       httpd_software: Apache/2.4.46 (Unix) OpenSSL/1.1.1j
       php_version: 8.1.13 64bit
       php_sapi: fpm-fcgi
       max_input_variables: 1000
       time_limit: 300
       memory_limit: 256M
       max_input_time: 300
       upload_max_filesize: 8M
       php_post_max_size: 32M
       curl_version: 7.86.0 OpenSSL/3.0.7
       suhosin: false
       imagick_availability: true
       pretty_permalinks: true
       htaccess_extra_rules: true
   
       wp-database
   
       extension: mysqli
       server_version: 10.5.9-MariaDB-1:10.5.9+maria~focal
       client_version: mysqlnd 8.1.13
       max_allowed_packet: 16777216
       max_connections: 151
   
       wp-constants
   
       WP_HOME: undefined
       WP_SITEURL: undefined
       WP_CONTENT_DIR: /var/www/html/wordpress/wp-content
       WP_PLUGIN_DIR: /var/www/html/wordpress/wp-content/plugins
       WP_MEMORY_LIMIT: 40M
       WP_MAX_MEMORY_LIMIT: 256M
       WP_DEBUG: false
       WP_DEBUG_DISPLAY: true
       WP_DEBUG_LOG: true
       SCRIPT_DEBUG: true
       WP_CACHE: false
       CONCATENATE_SCRIPTS: undefined
       COMPRESS_SCRIPTS: undefined
       COMPRESS_CSS: undefined
       WP_ENVIRONMENT_TYPE: Undefined
       DB_CHARSET: utf8mb4
       DB_COLLATE: undefined
   
       wp-filesystem
   
       wordpress: writable
       wp-content: writable
       uploads: writable
       plugins: writable
       themes: writable
       mu-plugins: writable
       ```
   
 * I traced around class-wp-query.php line.2134 wp_basename( $q[‘attachment’] ).
 * In my environment line.2092 elseif ( ” !== $q[‘pagename’] ) condition $q[‘pagename’]
   becomes “wp-admin/admin-ajax.php” and this process is entered so the processing
   of line.2134 is not executed.
 * This is a guess, but I feel like the server settings have something to do with
   it.
 * I presume that for some reason the request and query parameters to wp-admin/admin-
   ajax.php are not being passed to WordPress correctly.
 *  Thread Starter [reasonx](https://wordpress.org/support/users/reasonx/)
 * (@reasonx)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/#post-16354260)
 * Hi,
 * okay, then I will investigate further and search for the problem on our side.
   Thank you very much for your help.
 * Best regards

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problems with Plugin “TablePress”’ is closed to new replies.

 * ![](https://ps.w.org/plugin-load-filter/assets/icon-256x256.png?rev=1202972)
 * [Plugin Load Filter](https://wordpress.org/plugins/plugin-load-filter/)
 * [Support Threads](https://wordpress.org/support/plugin/plugin-load-filter/)
 * [Active Topics](https://wordpress.org/support/plugin/plugin-load-filter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/plugin-load-filter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/plugin-load-filter/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [reasonx](https://wordpress.org/support/users/reasonx/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/problems-with-plugin-tablepress/#post-16354260)
 * Status: resolved