This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Shekhar Bhandari 3 months, 1 week ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
July 1, 2019 at 10:13 pm #4122341

alisonB-2

On line 22 of wp-content/plugins/sitepress-multilingual-cms/classes/display-as-translated/class-wpml-cache-terms-per-lang.php there is a check to see if $new_terms is an array. In my case, $new_terms is an array but it is an empty array. (This Redis key returns "a:0:{}") This is causing the function to return false instead of rebuilding the cached value which prevents the taxonomy from being displayed on the WP admin tables. Can this be fixed to check if $new_terms is BOTH an array and NOT an empty array?

Thanks!

July 2, 2019 at 4:22 am #4123883

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Welcome to WPML support. I'd be assisting you further on this issue.

Which version of WPML are you using? For helping further on this issue it's very important to know your site related information such as themes used, plugins used, PHP versions etc. You can easily send this using Debug information settings from WPML.

So could you please go to WPML > Support > Debug Information and give me the information in the next reply. You can read the detailed instruction here: http://wpml.org/faq/provide-debug-information-faster-support/

Also, can you provide me steps to step guide to reproduce the issue in a new install?

Look forward to your reply.

Thanks

July 2, 2019 at 2:46 pm #4128095

alisonB-2

Hi Shekar - I already included the debug information in debug box on the ticket but here it is again.

July 2, 2019 at 2:56 pm #4128177

alisonB-2

Steps to reproduce the issue using WPML and Redis (https://wordpress.org/plugins/redis-cache/)

0. Use the site regularly on both the front and back end to build up your Redis cache
1. Create a new piece of content (in your parent or default language - in this case, English)
2. Assign it a custom taxonomy
3. Translate the content using the Classic Editor (in this case translate to French)
4. View your admin archive page in the translated language (French) [your_domain]/wp-admin/edit.php?post_type=post&lang=fr
5. The column for your custom taxonomy will be blank because the function terms_per_lang() returns false when the array is empty instead of rebuilding the cached taxonomy array.

July 7, 2019 at 7:18 pm #4158113

alisonB-2

Can we add the below custom taxonomy? It seems to happen more regularly on custom taxonomies. Thanks.

/**
 * Register custom taxonomies Audience.
 *
 * @since 1.0.0
 */
function jh_add_taxonomies_audience() {

	register_taxonomy(
		'jh_audience',
		array( 'post', 'page', 'jh_article', 'jh_blog', 'jh_bio', 'jh_events', 'jh_notice', 'jh_product', 'jh_press_release', 'jh_notice', 'jh_location' ),
		array(
			'labels'            => array(
				'name'                       => _x( 'Audience', 'Taxonomy General Name', 'jh' ),
				'singular_name'              => _x( 'Audience', 'Taxonomy Singular Name', 'jh' ),
				'menu_name'                  => __( 'Audience', 'jh' ),
				'all_items'                  => __( 'Audience', 'jh' ),
				'parent_item'                => __( 'Parent Audience', 'jh' ),
				'parent_item_colon'          => __( 'Parent Audience:', 'jh' ),
				'new_item_name'              => __( 'New Audience', 'jh' ),
				'add_new_item'               => __( 'Add New Audience', 'jh' ),
				'edit_item'                  => __( 'Edit Audience', 'jh' ),
				'update_item'                => __( 'Update Audience', 'jh' ),
				'view_item'                  => __( 'View Audience', 'jh' ),
				'separate_items_with_commas' => __( 'Separate audiences with commas', 'jh' ),
				'add_or_remove_items'        => __( 'Add or remove audiences', 'jh' ),
				'choose_from_most_used'      => __( 'Choose from the most used', 'jh' ),
				'popular_items'              => __( 'Popular Audiences', 'jh' ),
				'search_items'               => __( 'Search Audiences', 'jh' ),
				'not_found'                  => __( 'Not Found', 'jh' ),
			),
			'hierarchical'      => true,
			'public'            => false,
			'show_ui'           => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud'     => false,
			'rewrite'           => array(
				'with_front' => false,
			),
		)
	);
}
add_action( 'init', 'jh_add_taxonomies_audience', 0 );
July 8, 2019 at 4:32 am #4159001

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Yes, that's the test site so feel free to add it. You can add the code from Appereance->Theme Editor.

Let me know once it's reproduced.

Thanks

July 8, 2019 at 6:00 pm #4164827

alisonB-2

Hi - Sorry, I should have said that I already tried to do that but I got a permission denied error.

Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.
July 9, 2019 at 3:16 am #4167055

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I added the code to the site, also added the sftp details in the previous private reply so can you check it once and provide us the steps to reproduce it?

Look forward to your reply.

Thanks

The topic ‘[Closed] WPML_Cache_Terms_Per_Lang error checking for array is empty’ is closed to new replies.