pfefferle,
@pfefferle@mastodon.social avatar

is there a best practice to set plugin default settings or do (db) migrations on plugin install and update?

kraftner,
@kraftner@mastodon.social avatar

@pfefferle Whatever you do: Do not (only) rely on hooks that only trigger when using the standard, internal updating mechanism like https://developer.wordpress.org/reference/hooks/upgrader_process_complete/
There are way too many sites out there that update differently (manual, FTP, composer etc.)
Generally I'd say have an autoloaded option that stores the current version you compare with the current version. On mismatch start migration.
Also be careful to handle downgrades or other broken states and not solely rely on version info in the option

pfefferle,
@pfefferle@mastodon.social avatar

@kraftner the upgrader_process_complete is tricky anyway, because it is triggering the old code!

I hoped to avoid a regular check to save resources, but there seem to be no alternative :(

Thanks for your reply!

kraftner,
@kraftner@mastodon.social avatar

@pfefferle Well it basically is a single "if" comparing a string with an autoloaded option. I'd say the performance impact will be almost impossible to see even in a benchmark. If you've reached that level of performance optimization I really envy your codebase! 😉

  • All
  • Subscribed
  • Moderated
  • Favorites
  • wordpress
  • Durango
  • DreamBathrooms
  • cisconetworking
  • tester
  • ngwrru68w68
  • magazineikmin
  • osvaldo12
  • thenastyranch
  • rosin
  • Youngstown
  • slotface
  • everett
  • kavyap
  • mdbf
  • anitta
  • GTA5RPClips
  • provamag3
  • khanakhh
  • ethstaker
  • InstantRegret
  • tacticalgear
  • modclub
  • cubers
  • megavids
  • normalnudes
  • Leos
  • JUstTest
  • lostlight
  • All magazines