Make WordPress Core

Opened 13 years ago

Closed 4 weeks ago

#27814 closed enhancement (fixed)

Automatic updates should not be silently disabled if I have .hg in file system root

Reported by: jgehrcke Owned by: SergeyBiryukov
Priority: normal Milestone: 7.2
Component: Upgrade/Install Version: 3.7
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: administration

Description

My WordPress does not apply updates automatically, although it is told to via define('WP_AUTO_UPDATE_CORE', 'minor');. WordPress did not send any mail with an error report, so I had no idea how to debug that issue. I then found ​http://wordpress.org/plugins/background-update-tester/ which told me that all conditions pass except for

FAIL: The folder / was detected as being under version control (.hg).

What? Yes, indeed, I am managing system configuration files via Mercurial. The repo is placed in the root of my file system. This is *completely* unrelated to my WordPress installation.

I see the rational (​http://make.wordpress.org/core/2013/09/24/automatic-core-updates/):

If the install is running as a SVN or GIT checkout, automatic updates are disabled

But the way it is currently detected is in my opinion strongly over-generalized:

It looks for .svn, .git, .hg, and .bzr folders in ABSPATH, and every directory above that up to /

It is fine if WordPress makes assumptions about its own eco system. However, the current implementation assumes that any DVCS placed in any directory when going up the file system hierarchy up to the root is controlling WordPress. What is this assumption based on? That WordPress should be the only thing running on a Linux box? :-) Seriously, this is not a good way to detect if the current "install is running as a SVN or GIT checkout".

I think everybody agrees that I should not be forced to get rid of my system configuration repository in order to make automatic updates work again. I think WordPress should change this behavior.

What are other good ways of determining "if the install is running as a SVN or GIT checkout"? One could also question the rational behind this: If it is a SVN/GIT/... checkout then *most likely* it is a development version and the developer *most likely* does not want automatic updates to be enabled? Too many assumptions in this for my taste, even if we could reliably determine whether the current WP installation is a DVCS checkout.

Could that whole thing be done more explicitly?

What would be a quick workaround for me, if I really want to have automatic updates without getting rid of /.hg?

Change History (9)

#1 @nacin
13 years ago

  • Milestone Awaiting Review → Future Release
  • Version 3.8 → 3.7

Hi jgehrcke, thanks for the ticket.

When we did auto updates, we wanted to be super careful about stepping on toes. We turned on automatic updates by default for everyone and that was pretty scary for a lot of folks. To rationalize this, we coded it up for it to be as safe as possible, and that included assuming that if you were using any form of version control, then you knew better than us. It's possible that you have a website repository one, two, or more levels higher than WordPress core (which could easily be a subversion external or git submodule in this case).

Here, you trust the feature and don't want it to be so skittish about deciding whether to update your install. This is one of the best bug reports for a developer to receive. The automatic updater class is flattered.

There was a follow-up blog post on the same blog: ​http://make.wordpress.org/core/2013/10/25/the-definitive-guide-to-disabling-auto-updates-in-wordpress-3-7/. There, it explains the rationale with a bit more depth. And it also describes a simple filter you can use as a permanent workaround.

I think one thing we could do here is let WP_AUTO_UPDATE_CORE = 'minor' explicitly override certain things, since that's the default and it would only be specified if someone really wanted it.

#2 follow-up: @jgehrcke
13 years ago

Thanks for providing some background info to an ignorant user :-). Okay, so I have added the following code to my theme's functions.php:

--- a/functions.php	Mon Mar 24 17:59:47 2014 +0100
+++ b/functions.php	Tue Apr 15 14:19:08 2014 +0200
@@ -1,4 +1,12 @@
 <?php
+// Enable automatic update even if .hg or other VCS is detected.
+// http://make.wordpress.org/core/2013/10/25/the-definitive-guide-to-disabling-auto-updates-in-wordpress-3-7/
+function update_anyway($checkout, $context) {
+    return false;
+}
+add_filter('automatic_updates_is_vcs_checkout', 'update_anyway', 10, 2);

Correspondingly, the update check plugin now states:

INFO: The folder / was detected as being under version control (.hg), but the automatic_updates_is_vcs_checkout filter is allowing updates.

Is there a way to trigger the automatic update, or do I have to wait for WP cron to perform it?

You wrote

[...] since that's the default and it would only be specified if someone really wanted it.

Should that have been "since that's not the default"? In that case, I agree that setting WP_AUTO_UPDATE_CORE to 'minor' should either perform the backup or be verbose about the update progress/errors. Silently deactivation should not happen.

Thanks for consideration!

Version 0, edited 13 years ago by jgehrcke (next)

#3 in reply to: ↑ 2 @SergeyBiryukov
13 years ago

Replying to jgehrcke:

[...] since that's the default and it would only be specified if someone really wanted it.

Should that have been "since that's not the default"?

Well, the constant is not set by default, but updating to minor versions only is the default for the logic in Core_Upgrader::should_update_to_version()​.

#4 @johnbillion
13 years ago

One thing we could do is display more information on the Updates screen when automatic updates are disabled. This wasn't done in 3.7 when the auto updater was introduced because the feature is intended to be as silent as possible.

In this case, though, it would definitely save some head scratching if a message was added to this screen which states automatic updates have been disabled when a VCS is detected (and a link to more information).

#5 @chriscct7
11 years ago

  • Focuses administration added
  • Keywords needs-patch added

@johnbillion did you want to write a patch for comment:4?

This ticket was mentioned in ​PR #14506 on ​WordPress/wordpress-develop by ​@kraftbj.


4 weeks ago
#6

  • Keywords has-patch has-unit-tests added; needs-patch removed

When automatic updates can't run, the Plugins, Themes, and Updates screens still say "Automatic update scheduled in 6 hours." The automatic updater skips the update entirely when the site is under version control or when writing files needs FTP credentials, so that scheduled update never happens. We hit this on a site running trunk from an SVN checkout: it said the update was hours away for over a week.

wp_get_auto_update_message() now runs the same two checks as WP_Automatic_Updater::should_update(), against the same directory, and says why the update won't run instead. Users who can view Site Health get a link to it, since Site Health already explains both cases. On the Updates screen, the core section drops the schedule and the "kept up to date" line in either case.

The checks walk the filesystem, so the plugins and network themes list tables determine the message once per table instead of once per row.

To test, enable auto-updates for a plugin or theme that has an update available, then either:

  • create a .svn directory in the WordPress root, or
  • add define( 'FS_METHOD', 'ftpext' ); to wp-config.php without any FTP credentials.

Use of AI Tools

Issue discovered through dogfooding and investigated with AI. Human worked the code with AI review. AI suggested other surface areas (FTP)

​@kraftbj commented on ​PR #14506:


4 weeks ago
#7

Additional props should go to eidolonnight for investigation of the issue seen live, which led to discovery of the Trac ticket and the PR.

#8 @kraftbj
4 weeks ago

  • Milestone → 7.2

I took the direction in my PR that the behavior shouldn't change, but we should message that the autoupdates will not occur.

Setting the milestone so it can be considered as part of this cycle and not fall below the radar forevermore.

#9 @SergeyBiryukov
4 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 64586:

Upgrade/Install: Explain when automatic updates cannot run.

When automatic updates can't run, the Plugins, Themes, and Updates screens still say “Automatic update scheduled in 6 hours”. The automatic updater skips the update entirely when the site is under version control or when writing files needs FTP credentials, so that scheduled update never happens.

wp_get_auto_update_message() now runs the same two checks as WP_Automatic_Updater::should_update(), against the same directory, and says why the update won't run instead. Users who can view Site Health get a link to it, since Site Health already explains both cases. On the Updates screen, the core section drops the schedule and the “kept up to date” line in either case.

The checks walk the filesystem, so the plugins and network themes list tables determine the message once per table instead of once per row.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/14506.

Follow-up to r47835.

Props kraftbj, eidolonnight, jgehrcke, nacin, johnbillion, chriscct7, SergeyBiryukov.
Fixes #27814.

Note: See TracTickets for help on using tickets.