WordPoints / wordpoints

Points plugin for WordPress
GNU General Public License v2.0
20 stars 15 forks source link

Work around slashing bug in WordPress meta API #366

Closed JDGrimes closed 8 years ago

JDGrimes commented 8 years ago

While working on #364, I discovered a bug in the WordPress meta API in regard to meta keys that contain slashes. The bug has now been fixed in trunk, but I don't know if it will end up being backported or not. Even if it is, we'll likely want to implement a workaround for it anyway, just in case some users have auto-updates disabled (or the point releases don't get released before WordPoints 2.1.0).

JDGrimes commented 8 years ago

This was fixed upstream in 4.5, but we still support 4.4. So, unless we're going to drop 4.4 we need to work around this bug or else we'll have issues in the hooks API, which uses name\spaced meta keys.

JDGrimes commented 8 years ago

As I consider this more, working around it seems like a significant hack just to support a version that we'll be dropping in a few months anyway. And it will add overhead everywhere that our add meta functions are used. (We could check the WP version, but that adds a small amount of overhead as well.) Maybe though, there is a way that we could get the best of both worlds. We could just stop using the add meta functions anywhere in core for the time being. Doesn't actually fix the underlying bug, but the bug only affects places where meta keys containing slashes are being used anyway. So those places could do the work-around, while core would use use update meta functions everywhere else that it is possible.

JDGrimes commented 8 years ago

As far as I can tell, the only place in core where this bug is actually going to cause problems is in wordpoints_alter_points(). And since the log that we're adding metadata to will have just been created, there will be no real difference if we change to update meta anyway. So let's just do that and call this fixed.

JDGrimes commented 8 years ago

We could just stop using the add meta functions anywhere in core for the time being.

Unfortunately, the problem was actually in the update meta functions, not add meta. So b86c013 actually introduced this issue where it didn't actually exist. Let's revert that and everything should be OK. (I've checked if there is anywhere else that we are using update meta and slashed keys, and there doesn't appear to be.)

JDGrimes commented 8 years ago

Reverted in 6b5ded2dbc528132b3f47c21bdce37aef9703309.