Skip Navigation

[Resolved] New Toolset Relationships migration and API not working

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that when the user is migrating their relationships to the new API format they are getting errors in the migration log.
> Cannot return the number of found rows because the query was not instructed to obtain them.
> Cannot return the number of found rows because the query was not instructed to obtain them.
> Unable to migrate an association from post #0 to #10461 to a relationship : Unable to load posts 0 (0).

Solution:

This issue was actually fixed in our Types 3.0.2 version, if you're experiencing this issue I would recommend updating to this version of Types.

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Ana 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#917961

Ana

I am trying to:
I'm using a development/staging site with an up-to-date duplication of the production site, to test the upgrade of Toolset with the new Relationships feature.
I upgraded all Toolset Plugins in my site to the latest version (Types, Views, Forms and Access), with Types 3.0.1.
I perform the migration action.

Link to a page where the issue can be seen:
( the development/staging site is not a public site )

I expected to see:
I expected to have all existing relationships associations migrated. NONE was migrated.

Instead, I got:
Although the report said the migration was done and I got the page of Toolset > Relationships with all relationships with status "Migrated", none of the existing associations were migrated.
In the migration log I got a lot of:
> Cannot return the number of found rows because the query was not instructed to obtain them.
> Cannot return the number of found rows because the query was not instructed to obtain them.
> Unable to migrate an association from post #0 to #10461 to a relationship <...>: Unable to load posts 0 (0).

I tried several times the migration, with PHP 7.2, PHP 7.1, but the result was always the same.
So I investigated, and the table "toolset_associations" was completely empty.
All other toolset_<...> tables are populated and looking good.

I got the same issue in other site.
In this one, being less complex and with less information, I just manually populated the "toolset_associations" table, based on the already existing "_wpcf_belongs_<CPT>_id" post meta fields. I adjusted my custom code to use thew new Toolset Post Relationships API functions and everything is working fine.

My problem is: the migration for Types relationships is not working on these sites, why?

#918006

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ana,

Thank you for contacting our support forum.

Is this issue accross multiple sites or just one ?

DO you have any backups of the site before you ran the migration ?

Please let me know.
Thanks,
Shane

#918022

Ana

Well, it occurred at 2 different sites, that had post relationships.
Yes I have a duplicator for both sites. I'll prepare the duplicator of the smaller one.

Thanks

#918100

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ana,

Yes i'm enabling the private fields so that you can send the duplicator.

Thanks,
Shane

#918424

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ana,

I was able to perform the migrations with no issues at all.

So on your end the migrations don't even complete and you're presented with the errors you sent ?

Could you send me the debug data on the site ?
https://toolset.com/faq/provide-debug-information-faster-support/

Thanks,
Shane

#918433

Ana

Hi Shane,
In my end, with the site of the duplicator I sent, I performed the migration in my development site and in the end I also did it in the production site.
In the 3 attempts I made in my development site and also the one I made in the production site, the migration was completed, although with a lot of messages like:
> Cannot return the number of found rows because the query was not instructed to obtain them.
> Cannot return the number of found rows because the query was not instructed to obtain them.

And in the end with the following:
> Associations processed.
> The migration process is complete.

This is the site where I populated manually the "toolset_associations" table, as I need it working in the production site.
Note that in all the attempts running the migration the "toolset_associations" table was empty in the end.

I'm sending you my debug information, from the development site.

Thanks

#918458

Ana
Screen Shot 2018-06-27 at 18.29.20.png
Screen Shot 2018-06-27 at 18.25.21.png

Hi Shane,
I was curious about what you said that on your side the migration performed with no issues at all, and I repeated the process with the duplicator I sent you...
The result was exactly the same I described, but here is an image of the migration result and the detail of the migration log.

#918476

Ana

Hi Shane,
I hope this helps.
I was debugging you code (Toolset) and I found that Toolset, in my site, is using a Toolset common framework supplied by Toolset Views (wp-views), witch I presume is the latest version among Toolset plugins. And in the file:
/wp-content/plugins/wp-views/vendor/toolset/toolset-common/inc/m2m/association/query/association_query_v2.php

in the method Toolset_Association_Query_V2::get_results(), around lines 306-315 is this block of code:

		if( $this->use_cache ) {
			$cached_result_exists = false;
			$cache_key = $this->build_cache_key( $query );
			$cached_result = $this->cache_object->get( $cache_key, $cached_result_exists );

			if( $cached_result_exists ) {
				$this->clear_restrictions();
				return $cached_result;
			}
		}

When this code is run after the first time, the cache if found and returned.
In this situation, the internal property "found_rows" of the Toolset_Association_Query_V2 object is not set (staying null) and as the method was called with a "need_found_rows" set to true, the result is an exception being thrown:
"Cannot return the number of found rows because the query was not instructed to obtain them."

I don't know if my assessment is correct, but could you pass this information to your development team, as it might help bringing light to this issue.

#918531

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ana,

I'm going to escalate this one to our 2nd tier supporters as checking the duplicator again I was able to get the issue you were mentioning.

Thanks,
Shane

#919360

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ana,

I see where our team has fixed this issue and will be made available in the next release, which should be sometime soon.

Thanks,
Shane

#920344

Ana

Hi Shane,
I have updated the Toolset plugins to versions:
Toolset Types: 3.0.2
Toolset Views: 2.6.2
Toolset CRED: 2.0.1

And the issue reported here is solved.

Thanks for your support