UCF / Theme-Updater

A theme updater for GitHub hosted Wordpress themes. This Wordpress plugin automatically checks GitHub for theme updates and enables automatic install.
107 stars 35 forks source link

Issue with renaming theme directory after auto-update? #23

Open danyork opened 12 years ago

danyork commented 12 years ago

I noticed that there is an issue in the WordPress Forums related to the theme directory being renamed after an autoupdate:

http://wordpress.org/support/topic/plugin-theme-updater-changed-theme-path-after-upgrade

I've not experienced this myself, but I thought I'd log the issue here.

conover commented 12 years ago

The upgrader_source_selection_filter function in upgrader.php addresses this issue. If there are a set of steps to reliably reproduce this problem, I can look into it.

afragen commented 12 years ago

I am seeing this as well. New 3.4.1 WP install. Theme directory being renamed based upon git username, git repository and then seven character/digit combination. End result is after theme update the theme is no longer active.

afragen commented 12 years ago

BTW, now after renaming theme folder back, pushing a new tag to see if it works, I get the following error.

An error occurred while updating DRMCMedStaff: Update package not available..

Here's my repo, (https://github.com/afragen/drmcmedstaff) btw I don't think the instructions are correct. If I adde 'repo' to the end of this URI I get a 404 from github.

afragen commented 12 years ago

Update: error no longer present, theme updating and still selected, however theme folder renamed Username-TagName-Hash

scarstens commented 12 years ago

Agreed, having the same issue with the plugin. Note that the code I posted on the GIST with the version I use for the Whitelabel theme doesn't have this issue.

**All of this theme’s files are located in /themes/WordPress-Phoenix-whitelabel-framework-63a0b74.

This should just be /themes/whitelabel-framework

conover commented 12 years ago

I am still unable to reproduce this issue with a fresh WordPress install and the latest version of the theme updater. I even tried it with your theme, Dan, and there was no problem. There only thing I can think of is that there is a conflict with some other plugin involving the upgrader_source_selection filter.

scarstens commented 12 years ago

I think this is failing:

if(isset($source, $remote_source, $upgrader->skin->theme)){

As that was the issue for me. I'm trying to get you more information now but this part of the code is much harder to test.

conover commented 12 years ago

Quick and dirty: add a die(var_dump($source, $remote_source, $upgrader->skin->theme)); above that line to see which one is empty.

scarstens commented 12 years ago

Ok, have more info. Reference this GIST I used to debug... which might not be bad to leave in the plugin in general: https://gist.github.com/3219354

I got this response, also note that I have disabled the themes "updater" so there is nothing else running, no plugins except this plugin:

Updating Theme Whitelabel Framework (1/1) Downloading update from https://github.com/WordPress-Phoenix/whitelabel-framework/zipball/1.2.2… Unpacking the update… Installing the latest version… Executing upgrader_source_selection_filter()... !![SOURCE SELECTION FILTER FAILED]!! $source:'/home/ibseth2/public_html/wlwp.sethmatics.com/wp-content/upgrade/1.tmp/WordPress-Phoenix-whitelabel-framework-63a0b74/' $remote_source:'/home/ibseth2/public_html/wlwp.sethmatics.com/wp-content/upgrade/1.tmp'

Notice: Undefined property: Bulk_Theme_Upgrader_Skin::$theme in /home/ibseth2/public_html/wlwp.sethmatics.com/wp-content/plugins/UCF-Theme-Updater/updater.php on line 161 $upgrader->skin->theme:NULL Removing the old version of the theme… Theme updated successfully.

scarstens commented 12 years ago

Note that I am using the "bulk theme upgrader" from the updates panel:

/wp-admin/update-core.php

conover commented 12 years ago

Ah. That may explain the issue. I've been testing it from the Themes panel.

scarstens commented 12 years ago

More good info: http://phpdoc.wordpress.org/trunk/WordPress/Upgrader/Bulk_Theme_Upgrader_Skin.html

And the output of this object when upgrading: WP_Theme::__set_state(array( 'theme_root' => '/home/ibseth2/public_html/wlwp.sethmatics.com/wp-content/themes/', 'headers' => array ( 'Github Theme URI' => 'https://github.com/WordPress-Phoenix/whitelabel-framework', 'Name' => 'Whitelabel Framework', 'ThemeURI' => 'http://whitelabelframework.com/?github=updater_installed', 'Description' => 'Whitelabel Framework is designed to be the ideal Parent Theme for child theme development, and for use by freelancers and web developers to easily convert PSD to WordPress child themes. The theme options were built as modules, so turning off theme functionality is easy when you prefer to use a plugin instead.', 'Author' => 'Sethmatics', 'AuthorURI' => 'http://sethmatics.com/', 'Version' => '0.2.3', 'Template' => '', 'Status' => '', 'Tags' => 'white, black, orange, two-columns, left-sidebar, fixed-width, blavatar, custom-background, custom-header, custom-menu, editor-style, featured-image-header, featured-images, full-width-template, post-formats, sticky-post, theme-options, threaded-comments', 'TextDomain' => '', 'DomainPath' => '', ), 'headers_sanitized' => array ( 'Name' => 'Whitelabel Framework', 'TextDomain' => '', ), 'name_translated' => NULL, 'errors' => NULL, 'stylesheet' => 'WordPress-Phoenix-whitelabel-framework-63a0b74', 'template' => 'WordPress-Phoenix-whitelabel-framework-63a0b74', 'parent' => NULL, 'theme_root_uri' => NULL, 'textdomain_loaded' => false, 'cache_hash' => '8ac8410b603ee21d725c7e14d3c43a46', ))

i think we are approaching the solution now

conover commented 12 years ago

I understand what the issue is but I haven't been able to fix it yet. I won't have any time to work on this again until the end of the week though. Hopefully the issue will be fixed by the end of next week.

scarstens commented 12 years ago

I have a fix, a little while I will do a pull request and you can take a look at my solution

albertamentors commented 12 years ago

I have been having this problem as well :)

scarstens commented 12 years ago

your welcome to give my fork of the plugin a try if you can figure out how to update your files: https://github.com/scarstens/Theme-Updater

afragen commented 12 years ago

@scarstens I installed your fork, updated from the core-update.php and watched the plugin indicate that it updated correctly.

Updating Theme DRMCMedStaff (1/1) Downloading update from https://github.com/afragen/drmcmedstaff/zipball/0.8… Unpacking the update… Installing the latest version… Executing upgrader_source_selection_filter function... Renamed theme folder successfully. Removing the old version of the theme… Plugin reactivated successfully.Theme updated successfully.

Then I found that my theme vanished. Folder deleted from server. I tried this twice with same result.

afragen commented 12 years ago

and my twentyeleven folder now has my themes files, totally removing my twentyeleven theme.

afragen commented 12 years ago

On the upside using v.1.3.7 from the Themes page, does update correctly, issue clearly is with the core-update.php part

scarstens commented 12 years ago

is this a "child theme" that you are trying to update via GitHub? I definitely did not account for trying to update a childtheme using this plugin and believe I have it coded in to update based on the "template" foldername. honestly it would be better for the plugin to have an option to turn on debugging. I may build that tomorrow as the output used to be much more comprehensive in the version I built for my theme.

afragen commented 12 years ago

yes it is a child theme of twentyeleven, I'm happy to keep installing it and testing, But could you make some change so I can tell from the plugin page that it's your forked version. ;-)

scarstens commented 12 years ago

you can try my fork again. No I can't change the plugin to appear different in the repository because I submit my requested changes using the code from the fork. I wouldn't want any of the "temporary" changes to ever get accidently accepted into the main fork of the plugin.

afragen commented 12 years ago

@scarstens I can now confirm that your fork works here under the following conditions from both the Themes update and from core-update.php. In both cases the folder name for the theme stays the same as whatever it was. Example, if the folder name was [user]-[repo]-[hash] it will remain [user]-[repo]-[hash] after the update. If it was [repo] before, it will be [repo] after.

I was expecting the folder to be renamed [repo] as I would expect the script to grab the name from the [repo] and not base it on the name on my server. Is that an unrealistic or unexpected expectation?

Thanks.

scarstens commented 12 years ago

@afragen think about what that would do to a parent theme if the parent themes folder name changed on update... you would break all the child themes that reference it by "template" which was the folder name the theme was installed into. I think the way its currently setup works best.

afragen commented 12 years ago

I agree. The only reason I was seeing the [user]-[repo]-[hash] folder in the first place was because of the initial updating error.

danyork commented 12 years ago

Great to see the issue getting sorted out, even if I haven't yet run into it. Thank you all for working on it!

I'll note that the only times I was ever seeing [user]-[repo]-[hash] for the theme folder was when I was having people download the theme using the "Download as zip" button on the main Github page for my repo. This created a zip file using that algorithm for the folder name. When I upload that to the my site, it then installs into a [user]-[repo]-[hash] folder. However, once installed I have NOT seen it change, i.e. it continues to use the name. (And now I have people download a specific ZIP file that I have zipped up with the format of "[repo]", and that name, too, does not change.)

afragen commented 12 years ago

This seems to be exactly what I was seeing re: naming

scarstens commented 12 years ago

Yes, we built a "theme installer" for our theme to handle this issue. Your welcome to check it out: https://github.com/WordPress-Phoenix/whitelabel-framework/tree/Installer

It basically just a version of the theme that has no relevant contents, but it knows upon activation to go out and grab the latest version of itself from Github.