Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 379 #387

Merged
merged 55 commits into from
Apr 17, 2014
Merged

Issue 379 #387

merged 55 commits into from
Apr 17, 2014

Conversation

c3mdigital
Copy link

Fix #379
Fix #388
@fjarrett Please test and review

Chris Olbekson and others added 27 commits April 2, 2014 19:37
- get_instance() of WP_Stream_Install instead of calling check() method
- Add constructor method to initiate class then call check();
- Added prompt_update() method to handle user controlled db update
- Added final code documentation to class methods
- Fixed correct $_REQUEST keys to check for during each stage of update routine
- Replace esc_html with esc_html_e
- added error_log() calls to test installing over multiple versions
- fixed bug - move the update database button to the end of the function
- Moved the database user upgrade process outside of the plugin list table hook.  1st Update Database notice is still there but rest of routine lives on it's own.
-  Stores current connector versions and only fires callback function when version changes
- correct wp_stream_update query arg
…db update"

Reverting the screwy conflict merges
This reverts commit 1fceb01.
…xxx as naming convention"

This reverts commit 6b6d69d.
- Added filter for extensions call there own update routine
- Moved update routines to separate file
* To add your own stream extension plugin database update routine
* use the filter and return your version that updating from requires an update
* You must also make the callback function available in the global namespace on plugins loaded
* use the wp_stream_update_{version_number} version number must be a 3 character string number with no periods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c3mdigital Would it be at least 3 chars or exactly 3 chars?

Just thinking about double digit patch releases, like 1.4.12, which I believe is compatible with the semver spec.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett Actually it wouldn't matter as long as their callback function is the same

- Added filter for extensions call there own update routine
- Moved update routines to separate file
@c3mdigital
Copy link
Author

@fjarrett I just did the exact same steps above but this time downloaded version 1.1.2 and got the error message.

@frankiejarrett
Copy link
Contributor

@c3mdigital OK good, so I'm not crazy.

- Remove early return to allow multiple version updates to run
- return false early only if update function fails
- update functions should always return version string unless fail then they should return error object or false
@c3mdigital
Copy link
Author

@fjarrett The problem was the wp_stream_update114() function was returning true instead of the version number if the character set was already defined, https://github.com/x-team/wp-stream/blob/issue-379/includes/db-updates.php#L291

@frankiejarrett
Copy link
Contributor

@c3mdigital Right now, it's required that the plugin be updated via the WP dashboard in order for the DB update available message to appear, which is possible thanks to update_activation_hook.

However, if you manually overwrite the plugin files (like via FTP) you then have to deactivate/reactivate the plugin for the message to appear. This could cause a problem if the DB schema were to change via an update but the user never knew an update was available.

Would there be anything wrong with running WP_Stream_Install::check() all the time?

@c3mdigital
Copy link
Author

@fjarrett The check method already runs all the time on init.

@frankiejarrett
Copy link
Contributor

@c3mdigital Oh I see that now. OK so I was mistaken about having to deactivate/reactivate. Going to test again now.

@frankiejarrett
Copy link
Contributor

@c3mdigital OK the dialog works without the need to deactivate! Awesome.

However, the upgrade routines don't appear to be working:

  1. Install v1.2.8
  2. Change some checkboxes in Stream > Settings > General > Log activity for
  3. Change some checkboxes in Stream > Settings > Connectors
  4. Remove the plugin
  5. Clone in the latest and checkout issue-379
  6. Run the DB update when prompted
  7. There should be settings that migrated to Stream > Settings > Exclude but it's all empty

@c3mdigital
Copy link
Author

@fjarrett I see the issue. wp_stream_update_128() Never fires because version compare is only looking for less than https://github.com/x-team/wp-stream/pull/387/files#diff-0e76810e485377b380ecabaec99134abR243

If we change that to if ( version_compare( $db_version, $version, '<=' ) ) { Then the db function should run. I'll commit the change now.

-  Make sure db update function runs when updating from version that has update routine function
@frankiejarrett
Copy link
Contributor

@c3mdigital The upgrades are still not executing.

I don't think the version compare operator is the problem because the settings migrations were introduced in 1.3.0: https://github.com/x-team/wp-stream/blob/issue-379/includes/db-updates.php#L129

@c3mdigital
Copy link
Author

@fjarrett I see. I thought that was from version 1.2.8. Let me do some testing but it looks like running the update on the admin_notices hook is too late to add the action to wp_stream_after_connectors_registration

@c3mdigital
Copy link
Author

@fjarrett Can you test again. Since the update needs the connectors to be loaded I added a call to reload the class so the update can attach to the wp_stream_after_connectors_registration hook.

@frankiejarrett
Copy link
Contributor

@c3mdigital Worked! /five


do_action( 'wp_stream_before_db_update_' . $db_version, $current_version );

if ( version_compare( $db_version, '1.3.2', '<' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c3mdigital Just wanted to check with you on this one, this version compare shouldn't be required, right?

/cc @lukecarbis

frankiejarrett added a commit that referenced this pull request Apr 17, 2014
@frankiejarrett frankiejarrett merged commit d2f6e9b into develop Apr 17, 2014
@frankiejarrett frankiejarrett deleted the issue-379 branch April 17, 2014 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants