Title: Unknown post type on WP CLI
Last modified: January 29, 2025

---

# Unknown post type on WP CLI

 *  ResolvedModerator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/)
 * Hello,
 * I already use the plugin in some projects, but now I encountered a strange problem
   with the WP CLI.
 * It concerns an online store with thousands of products. In the browser, the delivery
   time is super optimized by the plugin.
 * The product data is regularly synchronized via WP CLI. The WordPress Importer
   plugin from WordPress is used for this, but slightly adapted for additional product
   data.
 * The problem:
   As soon as APCu Manager is activated, the import via WP CLI does
   not go through. An error message is then displayed for each product.
 *     ```wp-block-code
       Failed to import “XY42”: Invalid post type
       ```
   
 * This text is generated by the WordPress Importer plugin. Here is the location:
   [https://github.com/WordPress/wordpress-importer/blob/master/src/class-wp-import.php#L635](https://github.com/WordPress/wordpress-importer/blob/master/src/class-wp-import.php#L635)–
   apparently it no longer finds the post type as soon as APCu Manager is activated.
 * As soon as APCu Manager is deactivated, the message no longer appears and the
   import runs as it should.
 * Is there a solution for this? Many thanks in advance 🙂

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

 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18272431)
 * Hello [@threadi](https://wordpress.org/support/users/threadi/)
 * I must admit that’s strange error. Before going farther, can you confirm your
   cli versions (`wp --info`) and the status of APCu Manager (`wp apcu status`)?
 * Thanks a lot
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18274650)
 * Hi,
 * I have since investigated the problem further and have been able to narrow down
   the cause.
 * Back to the background:
   I am importing an XML file using the WordPress Importer
   plugin controlled by a WP CLI command. Since the XML file would otherwise be 
   gigantic, when we create it in an external CRM we omit many of the otherwise 
   uniform details about the products that are being imported. We then add this 
   uniform information before and during the import. My individual plugin provides
   the WP CLI command for this purpose, integrates the files of the WordPress Importer
   plugin for the import when it is called and sets a marker that the import is 
   now running. This marker is saved as a transient:
 *     ```wp-block-code
       set_transient( 'product_import_running', true );
       ```
   
 * The import then starts:
 *     ```wp-block-code
       $import_obj = new WP_Import();$import_obj->import( $xml_file );
       ```
   
 * We then use the “wp_import_posts” hook to add the missing information to the 
   posts from the XML. This also checks whether it is our import by loading and 
   checking the transient marker:
 *     ```wp-block-code
       // bail if our product import is not running.if ( false === get_transient( 'product_import_running' ) ) { return $posts;}
       ```
   
 * This also works without any problems without APCu Manager and its object cache.
   As soon as APCu Manager AND its object cache are activated:
 *     ```wp-block-code
       get_transient( 'product_import_running' )
       ```
   
 * always returns `false`. This means that the filter then returns the original 
   post array, which means that the information about the post types is missing,
   which explains the error message in the first post.
 * In summary: the problem is that APCu Manager apparently cannot handle transients
   on the WP CLI when the object cache is activated.
 * So that you can understand this, I have designed a small plugin that clearly 
   recreates the problem on a small scale. You can find it here: [https://github.com/threadi/apcu-test](https://github.com/threadi/apcu-test)–
   the testing procedure is described there.
 * The solution for my project will now be to switch from transient to a file flag
   to mark the ongoing import. However, an evaluation of my findings would still
   be interesting so that this does not happen to me or others in similar situations.
 * Then the requested information:
 *     ```wp-block-code
       OS:     Linux 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64Shell:  /bin/falsePHP binary:     /usr/bin/php8.2PHP version:    8.2.27php.ini used:   /etc/php/8.2/cli/php.iniMySQL binary:   /usr/bin/mysqlMySQL version:  mysql  Ver 15.1 Distrib 10.5.26-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapperSQL modes:WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cliWP-CLI vendor dir:      phar://wp-cli.phar/vendorWP_CLI phar path:       /var/www/clients/client0/web54/web/wp-content/plugins/apcu-testWP-CLI packages dir:WP-CLI cache dir:       /var/www/clients/client0/web54/.wp-cli/cacheWP-CLI global config:WP-CLI project config:WP-CLI version: 2.11.0
       ```
   
 *     ```wp-block-code
       APCu Manager 4.1.0 is running.APCu is not activated for command-line.WordPress object caching: enabled.Garbage collector: disabled.Analytics: enabled.Metrics collation: disabled.Logging support: no.
       ```
   
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18274660)
 * Wow, what a bug report <3
 * Just to be sure it’s a bug, could you try to activate APCu for command line?
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18275115)
 * Fascinating. Then it works. The transients are then saved and also used.
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18275121)
 * 😉
 * Glad to know it works now… Have a nice (object) caching journey!

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

The topic ‘Unknown post type on WP CLI’ is closed to new replies.

 * ![](https://ps.w.org/apcu-manager/assets/icon-256x256.png?rev=2225345)
 * [APCu Manager](https://wordpress.org/plugins/apcu-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/apcu-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/apcu-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/apcu-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/apcu-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/apcu-manager/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/unknown-post-type-on-wp-cli/#post-18275121)
 * Status: resolved