WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11209 closed defect (bug) (wontfix)

Problem when Trash is disabled when something is already trashed

Reported by: sirzooro Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Trash Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

When someone has some items trashed and then disable Trash (define EMPTY_TRASH_DAYS to 0), problems will appear:

  • all trashed items disappears from admin UI;
  • pages with trashed parents cannot be used as parents for other pages (they are not on the list);
  • WP displays following PHP notices for every trashed page and page with trashed parent while displaying list of possible parent pages for edited page.

Notice: Undefined offset: 2 in C:\wordpress29.local\wp-includes\post.php on line 2603
Notice: Trying to get property of non-object in C:\wordpress29.local\wp-includes\post.php on line 2603

There may be more issues related to this.

Attachments (1)

11209.diff (654 bytes) - added by caesarsgrunt 4 years ago.
Empty trash as soon as EMPTY_TRASH_DAYS is set to 0

Download all attachments as: .zip

Change History (11)

comment:1 follow-up: caesarsgrunt4 years ago

The first "problem" you've listed isn't really a problem - the items have been trashed and you don't want them restored. If anything you want them deleted when you disable trash, but as they will automatically be deleted anyway on the next run of wp_cron, this isn't an issue.

The second problem applies whether or not trash is disabled, and should be filed as a separate bug. I will do this in a minute.

The third problem - well, I don't get these notices.
I don't actually get any of the notices you've filed bugs for... what is your setup? Is it a plain default install of the latest trunk with no plugins etc? What version of PHP do you have?

comment:2 sirzooro4 years ago

For the 1st problem - If I disable the Trash, I would like to still see trashed items - e.g. just to delete them manually, before wp_cron will do this.

My setup: latest 2.9 nightly build, with default theme. I have most of my plugins installed and active, and WordPress Beta Tester. I use PHP 5.x (I will post exact version number later) with Xdebug. In wp-config.php I have WP_DEBUG and SCRIPT_DEBUG defined to true.

comment:3 caesarsgrunt4 years ago

Yeah; I see what you mean about the 1st problem - although the deletion by wp_cron will be pretty quick.
I'll make a patch later which causes trash to still b shown if there is anything in it.

Regarding the notices; would you mind trying a clean install without any plugins, just to eliminate the possibility that the notices are caused by a plugin?
Thanks.

comment:4 sirzooro4 years ago

I use PHP/5.2.9-2 on Apache/2.2.13 on Windows XP Pro.

Regarding 1st issue - I had page in trash. Then I disabled trash and tried to reproduce few warnings posted here earlier. This took me a while and I loaded many backend pages, but page was not deleted - is was still in trash when I enabled it again.

Regarding 3rd issue - looks that this duplicate of #11205.

comment:5 caesarsgrunt4 years ago

  • Keywords has-patch 2nd-opinion added; needs-patch removed

The patch resolves the issue by immediately emptying the trash when trash is disabled, rather than waiting until the next scheduled emptying (which could be up to 24 hours).

The patch also unschedules trash emptying when trash is disabled, so as not to waste resources.

Not sure that this immediate deletion is really necessary, but it does "fix" the "problem" described above where trash remains in the DB for up to 24 hours after setting EMpTY_TRASH_DAYS to 0.

caesarsgrunt4 years ago

Empty trash as soon as EMPTY_TRASH_DAYS is set to 0

comment:6 follow-up: azaozz4 years ago

-1. Don't think this is a bug, it's expected behavior: if you hide the trash without emptying it, there will be some items in it... Changing EMPTY_TRASH_DAYS to 0 is not something that would happen couple of times per week anyways.

comment:7 in reply to: ↑ 6 caesarsgrunt4 years ago

Replying to azaozz:

-1. Don't think this is a bug, it's expected behavior: if you hide the trash without emptying it, there will be some items in it... Changing EMPTY_TRASH_DAYS to 0 is not something that would happen couple of times per week anyways.

I agree with this, and would leave the behaviour as is. This also provides a safety net for anyone who disables trash and then wishes they hadn't.

Anyway, the patch is there if it is decided that the behaviour should be changed.

comment:8 in reply to: ↑ 1 lloydbudd4 years ago

Replying to caesarsgrunt:

The second problem applies whether or not trash is disabled, and should be filed as a separate bug. I will do this in a minute.

Continued in #11235.

comment:9 lloydbudd4 years ago

  • Milestone changed from 2.9 to Unassigned
  • Resolution set to wontfix
  • Status changed from new to closed

Based on caesarsgrunt and azaozz feedback, closing as wontfix.

comment:10 nacin4 years ago

  • Milestone Unassigned deleted
Note: See TracTickets for help on using tickets.