Jump to content

repeater/page delete - bug report


Rob
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • 3 months later...

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();}
Link to comment
Share on other sites

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); 
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 6 months later...

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
 Share

×
×
  • Create New...