-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Core-ify "Random Keywords" plugin #2367
Conversation
Using str_shuffle means that each character can only occur once in the generated string. This reduces the number of permutations possible. For example, using base 36, and 4 characters, there are 36^4 = 1.68M, but the current function can only generate 36*35*34*33 = 1.41M of these. This alternative will use the whole range of possible strings.
Allow character to appear more than once
* Rename plugin and its functions * Update README with new name * Update license with current year * Make plugin refuse to activate if the old 'Normal plugin' version is still active.
This was formerly an external plugin named `random-keywords`. History from the `random-keywords` repo is kept.
I for one really don't care about the git log and commit message history :) (I mean, nicely put commit messages are nice to have, but they shouldn't dictate the way one works) |
@LeoColomb I don't exactly remember what I still wanted to do with this. There was something, but I don't think I have time to look from a computer until tomorrow. |
😉 |
Oh yeah. Maybe also a real option instead of |
If strlen($possible) is for example 36, rand could also return 36. But substr starts with position 0. So we have to subtract 1 from strlen($possible). ---- Yoinked from YOURLS/random-keywords#10 by @dgw
So I had a bit of time tonight after all. There's already a "conflict preventer" function that checks if the old plugin is active. It might not actually prevent loading this one in that case; I haven't had a chance to test it. (Honestly, I've been unable to find much useful documentation about how hooks are supposed to work. Do I just But I noticed there was a merged PR in the other repo and pulled in those changes (tiny one-liner), and implemented a settings page which should work. 🤞 |
Yep, saw this PR, will have time to look at it tomorrow :) |
Nope, won't work ... There's a missing Plus, I think checking with Also, it's hooked onto Maybe a simple way would be something like:
Thoughts ? |
I was going to actually do some of this now, but I've run out of time. 😔 So it'll get done during the next block of free time I (think I) have.
The idea was to block activating the plugin entirely, but it looks like there's no hook capable of doing that. All of the plugin activation hooks run after the activation itself is already finalized. So, I'll have to overwrite that (stub) implementation with a different approach—probably based on detecting the old plugin's function name, yes.
I'm spending too much time in Python these days… 🤣 But replacing the conflict preventer as discussed above will eliminate this error anyway. |
Code is nowhere close to ready, so having an approval on it is very misleading!
The conflict preventer function was broken anyway (ineffective logic AND incorrect syntax)
There, @ozh, I think that's more like what you were suggesting. Better? |
Hmm, still doesn't work: having old one activated and activating new one, I get the expected notice but the plugin is still activated :
Will look into it |
Meh. I'm dumb. Works completely as expected. :-) |
Plugin integrated in the core Ref YOURLS/YOURLS#2367
@ozh Would it be possible to push a new release (e.g. v1.7.5) which includes this commit? It's been almost four months. |
Totally. Will do this week-end |
Any update on this? I just installed YOURLS and am liking it, but just noticed that random urls wasn't there and the docs say to enable the bundled plugin (that's not in the 1.7.4 release) |
Yeah, sorry for my lack of reaction, I'm awfully short on free time :) |
@ozh Thanks! How long does it typically take for new versions to appear on YOURLS' Docker Hub page? |
@whalehub It tipycally takes two days. It's done almost automatically, but some manual steps are required from outside of YOURLS team. |
* 'master' of https://github.com/YOURLS/YOURLS: Bump for next release Bump bumped version number (YOURLS#2595) Add vector version of YOURLS logo (YOURLS#2548) Trim overlong client information (YOURLS#2574) Rearrange opencollective badges Add jsonp parameter in API as a fallback to match documentation (YOURLS#2567) Update plugin.php (YOURLS#2562) Fix composer warning about uppercase in require block (YOURLS#2557) Split test in 2 (YOURLS#2558) Core-ify "Random Keywords" plugin (YOURLS#2367)
This is still WIP, don't merge yet. In particular, the check desired in #1877 for whether the standalone plugin is active doesn't do anything/might even crash the whole plugin (I've not tested it yet).
Mostly I'm looking for feedback on whether or not it's worth keeping the commit history of the original plugin. I did this with a merge using
--allow-unrelated-histories
. For the final PR, I can either prefix the merged-in commits with something so it's clear they pertain to the plugin, not YOURLS itself, or just remove the history and do a copy-paste import instead. What say you @ozh @LeoColomb?Whatever the way forward, it's clear that having this functionality as a core plugin will (hopefully) reduce the number of issues/comments asking how to avoid sequential shorturls.