Jump to content

Recommended Posts

Posted

Apologies if this isn't the right forum section, I wasn't sure where to stick a bug report.

I've been toying with the development of a page draft module - http://processwire.c...ease-feed-back/ - and in the process I think I've stumbled upon a bug with repeater fields and page cloning/deleting.

If I create a new page, or clone an existing one with an API function call, that has a repeater field then the number of rows in the relevant DB table increases by 1 as might be expected. However when I delete that page the DB table row count does not drop by one, it stays the same. If this is indeed a bug and not some intentional behaviour that I'm not understanding, then there is the potential for "orphan" data in that table.

Ryan - does this sound correct to you?

This is only based on a few brief tests so it may be worth some other users doing some tests to see if this is repeatable.

Posted

Thanks for the report. Since there are a lot of DB tables involved with repeaters, which DB table specifically do you mean? Also can you confirm that the deleted page is not still in the trash? (meaning it was really deleted and not trashed)

  • 3 months later...
Posted

Hello, I need to ressurect this thread for an old problem of mine. I still cannot delete repeater fields, no matter how hard I try. This is the latest approach and still all the repeaters stay intact. In the pages table, 814 pages with parent "for-field-125" remain. What am I doing wrong?

$pa = wire('pages')->find("template=video,include=all");
		foreach($pa as $p) { 
			foreach($p->files as $file) {
				$p->files->remove($file);
			}
			$p->save();
			$p->delete();}
Posted

I wasn't able to duplicate this before, but will give it another try.

One thing I want to mention is that you've got some extra unnecessary code in there. There's no reason for you to go delete the files separately. What you want is this: 

$pa = wire('pages')->find("template=video,include=all");
foreach($pa as $p) wire('pages')->delete($p, true); 

Note the second "true" argument to the delete function. That makes it recursively delete any children too. Otherwise, if your pages had children, they wouldn't be deleted. 

Another approach you can take is to trash them. Then when you later empty the trash, they should all be deleted.

foreach($pa as $p) wire('pages')->trash($p); 
Posted

Thanks for your answer Ryan,

I just tried your code and the repeaters still remain in the DB. The unneccessary code was my attempt at forcing PW to delete the repeaters but that didn't work either. Could this be an issue of how the repeaters were created? 

Thanks,

t

Posted
Could this be an issue of how the repeaters were created? 

So long as it was ProcessWire's FieldtypeRepeater that created them, it shouldn't matter. What version of ProcessWire are you running?

  • 6 months later...
Posted

Assuming this is what I think it is, see the fix in this post. I'm not exactly sure why this error appears in some instances, but if you apply that change (or switch to the dev branch) that will hopefully fix it. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...