Make WordPress Core

Opened 7 years ago

Closed 3 years ago

#39917 closed defect (bug) (worksforme)

AutoSave is not disabling in spite of settings added in wp-config.php

Reported by: subrataemfluence's profile subrataemfluence Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.2
Component: Autosave Keywords:
Focuses: administration Cc:

Description

I want to disable AUTOSAVE for my application. For this I have added the following lines in /var/www/html/mysite/wp-config.php file:

/* AutoSaving and Revisions */

define( 'AUTOSAVE_INTERVAL', 20000000000 ); // autosave 1x per year
define( 'EMPTY_TRASH_DAYS',  0 ); // zero days
define( 'WP_POST_REVISIONS', false ); // no revisions

/* That's all, stop editing! Happy blogging. */

But WordPress is still doing AutoSave.

OS: Ubuntu 14.04
WordPress Version: 4.7.2

Change History (7)

#1 @dd32
7 years ago

  • Keywords reporter-feedback added

Hi @subrataemfluence

Can you explain why you believe autosave isn't disabled?

Quite often people will see auto-draft status posts created, these are not related to autosaves and aren't able to be disabled as they're a core part of the administration interface, they're often confused by people to think that it's autosave-related.

#2 @subrataemfluence
7 years ago

Thank you for quick reply! Before everything I would like to introduce myself as a WordPress beginner. So I am sorry if my understanding is not right about autosave and auto-draft.

All I want is the ability to tell WordPress whether or not to SAVE a post while I am adding it from the admin (or may be even from front end).

If autosave and auto-draft are different then I would like to stop WordPress to save auto-draft. Is there a way in WP core which I can use to accomplish what I looking for?

#3 @dd32
7 years ago

If autosave and auto-draft are different then I would like to stop WordPress to save auto-draft. Is there a way in WP core which I can use to accomplish what I looking for?

If your question was about preventing the auto-draft items being created, then no, there's no way to disable that functionality - it's core functionality of how the new post screen works, including adding categories/tags/uploads to posts before they're published. The post id of the auto-draft is re-used for the subsequent draft and then publish'd posts.

#5 follow-up: @subrataemfluence
7 years ago

  • Focuses administration added

Thank you. I did a few tests with auto-draft feature to understand what it exactly does.

  1. Removed the following block from wp-config.php
define( 'AUTOSAVE_INTERVAL', 20000000000 ); // autosave 1x per year
define( 'EMPTY_TRASH_DAYS',  0 ); // zero days
define( 'WP_POST_REVISIONS', false ); // no revisions
  1. Started creating a new post by adding a title. Draft auto-saved.
  1. Added a few lines in content editor, draft again auto saved
  1. Selected a native category taxonomy. Draft auto saved again and added a row in wp_term_relationships table for correct object_id
  1. Added a featured image - Auto Save did not add entries in wp_posts or wp_postmeta
  1. Selected a custom taxonomy I created for this post type. This did not get auto-saved with the post and no new row was added in wp_term_relationships table.
  1. Added information in custom meta boxes. They did not get auto-saved either.

Observation:

  1. Setting in wp-config.php does have some effect in preventing auto-drafting (auto-saving) partially. If I keep that on, only title and content gets auto saved and only once
  1. If the setting is not present, auto save occurs in a certain interval and saves title, content and native category taxonomy but not anything custom including featured image.
  1. Without the setting, auto save also works in edit mode but not when the setting is added.
  1. Without settings, auto save works on native category taxonomy but only when either title or the content is modified
  1. Closed the browser and opened the post back in edit mode this time. Only saved information are Title, Content and Category, no meta information or featured image. Means WordPress does not auto-save anything except post-type's native fields.

My understanding:

So what you have said is partially right - "there's no way to disable that functionality - it's core functionality...", but wp-config.php with and without settings applied do have impacts on auto-draft / auto-save functionality. Although so far we do not have the ability to completely disable the feature we can put some breaks on it!

#6 in reply to: ↑ 5 @azaozz
7 years ago

Replying to subrataemfluence:

It's a bit more complex :)

There are two autosaves:

  • to the server: creates a revision post or updates the post if it is a draft by the same author.
  • in the browser's sessionStorage: this is for "disaster recovery" and is accessible only if the browser crashes or the post cannot be saved, network is down, etc.

The user can only control the interval for the aurosave to the server. This was intended for reducing the server requests while the Edit Post screen is loaded (some very cheap hosting accounts had issues with too many requests). However now it's mostly a left-over as we use Heartbeat for autosaves.

Setting in wp-config.php does have some effect in preventing auto-drafting (auto-saving) partially. If I keep that on, only title and content gets auto saved and only once

Not quite. Auto-drafts cannot be disabled. As dd32 explained above they are user to "reserve" a row/post_ID in the posts table for the upcoming post when the user loads the Add New Post screen (and in few other cases). If no post is saved they are deleted a week later.

Without the setting, auto save also works in edit mode but not when the setting is added.

Right. Autosave to the server is triggered at least once after loading the Add New Post screen. This is not affected by the interval from AUTOSAVE_INTERVAL.

Can I ask why would you want to disable autosaves? They are there to safeguard the content typed by the users and are "basic functionality" that is always needed.

#7 @hellofromTonya
3 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

As shared as dd32 and azaozz noted, autosaves is working as intended to provide the "safeguards" and "basic functionality". It's not a defect. Rather, it's a design design to ensure the content typed by users is safeguarded. Past tickets for this same report provide valuable insights on why it is designed this way such as #17654, #18800, #19310, #20168.

Completely disabling it has risks to the content. Doing so is plugin territory. There are benefits to moving this to a plugin such as a plugin can solidify the solution, eliminate the risks, and validate the use case.

Note: See TracTickets for help on using tickets.