froger-me / wp-packages-update-server

WP Packages Update Server - Run Your Own Update Server for Plugins and Themes
GNU General Public License v3.0
141 stars 39 forks source link

Updates from localhost dev on windows. #2

Closed digitalbread closed 6 years ago

digitalbread commented 6 years ago

Updating from localhost dev on windows still not working. To me it would be important that it is compatible with localhost on windows development mostly because wordpress.org and the https://github.com/YahnisElsts/plugin-update-checker do also work.

I think you find the issue in your function that creates the plugin_id for the endpoint (plugin_id=dummy-plugin%2Fdummy-plugin.php) on localhost for windows is sending (plugin_id=C%3A%5C%5CX%5C%5CAAA_PHPSTORM_PROJECTS%5C%5Cmyproject.dev.cc%5C%5Cwp-content%5C%5Cplugins%5C%5Cdummy-plugin%5C%5Cdummy-plugin.php) In the localhost dev site admin > Plugins > Dummy Plugin v1 > Check for Updates when I try and update I get this error: Could not determine if updates are available for Dummy Plugin. HTTP response code is 404 (expected: 200) puc_unexpected_response_code Thanks @froger-me

froger-me commented 6 years ago

Hmmm... I've put together a dev environment on localhost - the only issue it that it's on Mac OSX with MAMP. I do not have Windows, only OSX or Linux...

Under both Linux and OSX local environments, the dummy plugin is successfully pulling its updates from the remote Wordpress where WPPUS is installed - both mine, and yours (tested twice with yours - grabbing your dummy plugin, then decreased the version number, then retest the whole update process successfully) - so I cannot reproduce so far.

digitalbread commented 6 years ago

@froger-me OSX uses a Unix directory structure so the paths will be the same as Linux hosting. I'm sure the problem is only on Windows local dev and possibly Windows Hosting Servers. Maybe you could try Windows in Parallels on your MAC. If not when I get some time I'll look into it. Thanks

froger-me commented 6 years ago

I think I found the issue - I used to explode the file path with explode( '/', $plugin_file_path ); everywhere, including in the dummy packages. I replaced by explode( DIRECTORY_SEPARATOR, $plugin_file_path ); (untested, but that should do the trick) and increased version number to 1.0.2 on Wordpress SVN repository.

At least it'd fix the issue for the client plugins.

Windows... I've gotta add a notice somewhere saying that the compatibility of the server plugin with Windows hosting is not guaranteed.

digitalbread commented 6 years ago

@froger-me I updated the wppus to 1.0.2 and clicked check for updates from windows localhost. I got the error: Could not determine if updates are available for Dummy Plugin. HTTP response code is 404 (expected: 200) puc_unexpected_response_code so I looked in the request.log and there was no entry. I then tested the endpoint https://my-domain.tld/wp-update-server/?update_action=get_metadata&plugin_id=dummy-plugin%2Fdummy-plugin.php and got a 404 I went into wppus under the General tab and the package was missing. I tried under "Add a package from the remote repository" dummy-plugin and get this error: Error - could not get remote package. Check if a repository with this slug for a package of type "Plugin" exists and has a valid file structure nothing changed at bitbucket and I double checked to make sure. So it seems something went wrong with the 1.0.2 update. Here sis the Fatal Error from the debug.log running the wppus plugin v1.0.2 `PHP Fatal error: Uncaught RuntimeException: The update checker cannot determine if "dummy-plugin" of type "" is a plugin or a theme. This is a bug. Please contact the ProxUC developer. in /srv/users/userandappdir/apps/userandappdir/public/wp-content/plugins/wp-plugin-update-server/lib/proxy-update-checker/Proxuc/Factory.php:42 Stack trace:

0 /srv/users/userandappdir/apps/userandappdir/public/wp-content/plugins/wp-plugin-update-server/inc/class-wppus-update-server.php(387): Proxuc_Factory::buildUpdateChecker('https://bitbuck...', 'dummy-plugin', 'dummy-plugin.ph...', NULL, '/srv/users/digi...')

1 /srv/users/userandappdir/apps/userandappdir/public/wp-content/plugins/wp-plugin-update-server/inc/class-wppus-update-server.php(112): Wppus_Update_Server->init_update_checker('dummy-plugin')

2 /srv/users/userandappdir/apps/userandappdir/public/wp-content/plugins/wp-plugin-update-server/inc/class-wppus-update-server.php(75): Wppus_Update_Server->save_remote_package_to_local('dummy-plugin')

3 /srv/users/userandappdir/apps/userandappdir in /srv/users/userandappdir/apps/userandappdir/public/wp-content/plugins/wp-plugin-update-server/lib/proxy-update-checker/Proxuc/Factory.php on line 42`

Hope this helps, thanks

froger-me commented 6 years ago

Ok - I see what happened here...

Basically, the update nuked everything on the server's folders (and that's part of a plan I have for next version, namely put all the packages, logs etc... outside of the plugin folder - seems obvious, but was not included in v1 since, well, it's v1 and it was doing the job for me).

What I'm not sure is happening here though is where the package type is not recognized. Funnily enough, after updating to WPPUS v 1.0.2 on my server, grabbing the package again by entering dummy-plugin in the input box of "Add a package from the remote repository (recommended)", and updating the client using said package, the whole process went fine.

Let me investigate more then.

froger-me commented 6 years ago

Hmmm... I replicated your remote settings (found in the "Packages remote source" tab) on my own install, and it's still working.

I'd like to reinstall the plugin on your install, if that's ok.

digitalbread commented 6 years ago

@froger-me That's really weird. You do see the error in General when trying to get the package on my wppus server though right? Should I reinstall? Not sure what to do next.

froger-me commented 6 years ago

I do see the error - I'm currently trying to debug on your server (basically, check why the type of package is not found). May I know where the error_log result is output? I saw the debug.log's content, but it suddenly went blank, and now when I try to tail it, no error_log is output in it.

digitalbread commented 6 years ago

sorry I was trying to troubleshoot also and cleared the log to see if I get a new entry. Now the error I posted above is not being created. Sorry about that, I'll stay out of there while you work on it.

digitalbread commented 6 years ago

The only other thing I did was update the mu-plugins/wppus-endpoint-optimizer.php to the version that is in wppus 1.0.2

digitalbread commented 6 years ago

I emailed you the error that I saw before I obscured it for posting it here.

froger-me commented 6 years ago

For some reason a transient I use as a semaphore was still set to true... Removing it fixed the error. No idea why it was there in the first place, as every outcome possible in the function ends up with its deletion. Anyway, you're good to go and test with the local install - the remote server is working.

digitalbread commented 6 years ago

@froger-me Thank you for fixing that. When I test localhost on windows update I still get this error Could not determine if updates are available for Dummy Plugin. HTTP response code is 404 (expected: 200) puc_unexpected_response_code

Emailing you the error from the wordpress debug.log on localhost where dummy-plugin v1.1 is and trying to update.

froger-me commented 6 years ago

Way to go, me... Doing things half way...

What happens if you add a wp_normalize_path on __FILE__ in the dummy plugin? I forgot one...

Basically, replacing:

/** Enable updates without license check **/
$dummy_plugin_updater = new WP_Plugin_Updater(
    'https://your-update-server.com',
    __FILE__,
    wp_normalize_path( plugin_dir_path( __FILE__ ) ),
);

with:

/** Enable updates without license check **/
$dummy_plugin_updater = new WP_Plugin_Updater(
    'https://your-update-server.com',
    wp_normalize_path(__FILE__),
    wp_normalize_path( plugin_dir_path( __FILE__ ) ),
);

(Really gotta upgrade my machine and run windows...)

digitalbread commented 6 years ago

@froger-me that did the trick. I've updated successfully from locahost dev on windows. Way to go and thank you!!!

froger-me commented 6 years ago

You're welcome! I'm gonna update the repo now, thanks to your tests - no need for you to update though, changes will be only in the dummy packages.

Thank you very much for the help and patience!