[02:39:18] [1/5] bro [02:39:18] [2/5] https://cdn.discordapp.com/attachments/1006789349498699827/1495252421075669063/1.jpg?ex=69e591d5&is=69e44055&hm=fcb2e98df3eec3d7c5f91793f3fb552374c4bfa8db5bbcf3aff53bc14e1709a3& [02:39:18] [3/5] https://cdn.discordapp.com/attachments/1006789349498699827/1495252421654478868/2.jpg?ex=69e591d5&is=69e44055&hm=8eae8a5c2cce8fd9367b78989fb5274dd67dff22eadcf6d6f800d2596d221eb7& [02:39:19] [4/5] https://cdn.discordapp.com/attachments/1006789349498699827/1495252422095016059/3.jpg?ex=69e591d5&is=69e44055&hm=12c3230a67b7368ac367217f23f0d8f356797f1787d600bc2f1064c3390d6fdf& [02:39:19] [5/5] https://cdn.discordapp.com/attachments/1006789349498699827/1495252422573031495/4.jpg?ex=69e591d5&is=69e44055&hm=953e574ef10e96ae9400de3848ea806ce78bdbcfa164a851db09ce2102370e20& [03:14:36] @posix_memalign where did you stash the config changes i had btw [03:14:53] not a big issue i just dont wanna remake custom protection levels on nano [03:35:55] [1/8] ``` [03:35:55] [2/8] petramagna@test151 /s/m/config> sudo -u www-data git stash list [03:35:56] [3/8] stash@{0}: WIP on main: 014275a9 Enable SecurePoll on beta for testing (#6372) [03:35:56] [4/8] stash@{1}: WIP on main: 3338640a Standardize/fix links to m:Phorge in extension descs (#6340) [03:35:56] [5/8] stash@{2}: WIP on patch-bucket: 0da0443f Use vestyle instead of check [03:35:56] [6/8] stash@{3}: WIP on patch-bucket: 0da0443f Use vestyle instead of check [03:35:57] [7/8] ``` [03:35:57] [8/8] I think 0 is the one that you want to pop. [03:36:25] What path [03:36:45] `/srv/mediawiki-staging/config` [03:36:52] `/s/m/config` is fish's shorthand notation. [03:43:54] Seems not 0 [03:44:03] thats just LocalWiki.php [03:53:51] [1/2] It's the one after that. Run `sudo -u www-data git stash show -p` to preview. [03:53:51] [2/2] https://cdn.discordapp.com/attachments/1006789349498699827/1495271184600797287/image.png?ex=69e5a34f&is=69e451cf&hm=7f60e1d258f5256f642457d7294b74a0466e52a9a3b354f8ac3aa43ae02cc36a& [03:55:08] Thanks! [03:55:21] Do we still need that first stash? [03:55:22] Btw I don't know if you saw https://issue-tracker.miraheze.org/T5991. Not sure if it's related to what you are doing though. [03:55:34] You can put it back into the stash with `git stash` [03:55:58] yeh was lookinga t that [03:56:05] i accidently git added to i gotta restore [03:56:12] my brain is shutting down so [03:56:28] I also don't know what it's about and can't say for certain unless I'm the author. [03:57:17] There was another task maybe about adding custom perm levels to MW but thats much more complicated [03:57:25] ask me to explain tommorow im about to pass out [04:00:20] okay done [04:09:58] hahaha [04:10:07] @posix_memalign seems like it's working! [04:10:42] okay im dipped if you wanna give it a shot the custom levels are on testwikibeta, global-admins has the right globally and rollbacker has it locally [04:11:17] Debugging something else rn so I guess this is up for grabs if anyone else sees this and is interested. [04:11:33] totes [04:11:37] I'll update the task tmr [04:13:19] [1/15] ```diff [04:13:20] [2/15] diff --git a/extension.json b/extension.json [04:13:20] [3/15] index aab58c5..b3da920 100644 [04:13:20] [4/15] --- a/extension.json [04:13:20] [5/15] +++ b/extension.json [04:13:21] [6/15] @@ -34,7 +34,8 @@ [04:13:21] [7/15] "Miraheze\\MirahezeMagic\\Maintenance\\": "maintenance/" [04:13:21] [8/15] }, [04:13:22] [9/15] "ExtensionFunctions": [ [04:13:22] [10/15] - "Miraheze\\MirahezeMagic\\HookHandlers\\NoFollow::registerHooks" [04:13:22] [11/15] + "Miraheze\\MirahezeMagic\\HookHandlers\\NoFollow::registerHooks", [04:13:23] [12/15] + "Miraheze\\MirahezeMagic\\HookHandlers\\UserRights::registerHooks" [04:13:23] [13/15] ], [04:13:24] [14/15] "LogActionsHandlers": { [04:13:24] [15/15] "vanishuser/*": "MediaWiki\\Logging\\LogFormatter"``` [04:13:41] [1/35] ```php [04:13:41] [2/35] [3/35] namespace Miraheze\MirahezeMagic\HookHandlers; [04:13:42] [4/35] use MediaWiki\Permissions\Hook\UserGetRightsHook; [04:13:42] [5/35] use MediaWiki\MediaWikiServices; [04:13:43] [6/35] class UserRights implements UserGetRightsHook { [04:13:43] [7/35] public function __construct( [04:13:43] [8/35] // private readonly Config $config [04:13:43] [9/35] ) { [04:13:44] [10/35] } [04:13:44] [11/35] public static function registerHooks(): void { [04:13:45] [12/35] $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); [04:13:45] [13/35] $handler = new self(); [04:13:46] [14/35] $hookContainer->register( [04:13:46] [15/35] 'UserGetRights', [04:13:47] [16/35] [ [04:13:47] [17/35] $handler, [04:13:48] [18/35] 'onUserGetRights' [04:13:48] [19/35] ] [04:13:49] [20/35] ); [04:13:49] [21/35] } [04:13:50] [22/35] public function onUserGetRights( $user, &$rights ) { [04:13:50] [23/35] if ( in_array( 'editallcustomprotected', $rights ) ) { [04:13:51] [24/35] $rights[] = 'editalphaprotected'; [04:13:51] [25/35] $config = MediaWikiServices::getInstance()->getMainConfig(); [04:13:52] [26/35] if ( count( $config->get( 'RestrictionLevels' ) ) > 4 ) { [04:13:52] [27/35] foreach ( $config->get( 'RestrictionLevels' ) as $right ) { [04:13:53] [28/35] if ( !in_array( $right, [ '', 'user', 'autoconfirmed', 'sysop' ] ) ) { [04:13:53] [29/35] $rights[] = $right; [04:13:54] [30/35] } [04:13:54] [31/35] } [04:13:55] [32/35] } [04:13:55] [33/35] } [04:13:56] [34/35] } [04:13:56] [35/35] }``` [04:13:57] in case they get lost on beta overngiht lol [04:14:31] gave it a composer fix and im off [13:18:43] https://cdn.discordapp.com/attachments/1006789349498699827/1495413336588947526/IMG_20260409_064348_446.jpg?ex=69e627b2&is=69e4d632&hm=90f2fedd5eafcb8dbb319ca7fd68828722242ad155acc403e49ecd05b5930251& [16:33:53] Hm, does Phorge not display patch files as text [16:33:54] lame [16:34:44] Anyhow https://issue-tracker.miraheze.org/T14439#305246 [16:38:32] I'd recommend removing the count() condition [16:38:43] and using array_diff to get custom levels [16:39:22] you can just set $rights to the merged result of $rights and the diff [16:39:42] aha [16:39:48] better idea! [16:40:06] does array_merge deduplicate? [16:40:09] also, do we have to use the hack with the extension function here? [16:40:46] uh not 100% sure but I don't think so [16:41:01] just deduplicate with array_unique ig [16:41:13] Far as I can tell it's the easiest way to make sure this hook runs after CA's global rights are added to &$rights [16:41:24] But if there's a better way I'm open to it [16:41:27] the hook function needs an @inheritDoc [16:42:11] there is still orphaned code in the constructor [16:42:13] But also given we already use the same thing (ExtensionFunctions) in MirahezeMagic I don't really see an issue [16:42:30] what is editalphaprotected [16:42:34] the constructor part was admitted me copy and pasting from other files and being not fully sure what is needed [16:42:41] wait is that in there?? [16:43:00] That was the custom level I put on beta to test, that shouldn't be in the patch [16:43:09] I prob goofed [16:43:11] only because we introduced a hack a couple weeks ago doesn't mean we should necessae do the same again [16:43:20] Also true [16:43:53] i think editallcustomprotected is missing the associated message(s) [16:44:06] ..right, that [16:44:08] Theres probably a structure test for that in core that will fail [16:44:24] Okay let me jot a list for latter [16:44:45] [1/2] * add messaegs for new right [16:44:46] [2/2] * dont include test stuff in the LS patch lol [16:45:31] the test stuff is in the MM patch [16:45:41] wait [16:46:13] the hell [16:46:17] lol [16:46:21] okay thats prob me being a dumb ass [16:46:33] if you cant tell I'm not exactly a good PHP dev LOL [16:46:47] I'd recommend using a local dev env btw [16:46:57] mw-dev-kit supports centralauth nowadays [16:47:01] yeah i already downloaded PHP storm so i dont have to keep using nano [16:47:05] there's a guide for it [16:47:13] I'll see later yea [16:47:14] even SUL3 [16:47:16] does it work on windows [16:47:21] no [16:47:26] exploding [16:47:29] although [16:47:31] not sure [16:47:34] it's dockerized [16:47:42] im still working on getting linux on this laptop [16:47:45] the guide certainly won't work on windows [16:48:04] but i dont really have that much time to keep messing with kernel nonsense i jsut wanna get a bit of wiki work done [16:48:15] just install wsl2 in the ms store lol [16:48:27] will look at that later [16:48:48] i gotta get going soon so ill get back to this later [16:49:17] side effect of being self taught and never doing much tech contribs for an org larger than 3 people in tech is showing llol [16:49:49] and PHP storm cant install git [16:49:50] awesome [16:49:55] uuuuuuuuuugh [16:50:19] being self taught is not a bad thing [16:50:34] I don't think it is at all [16:50:46] I learned none of the skills I use today in school [16:50:50] I mean, I think I can and have done really cool stuff, and I never paid a dime for the stuff I know [16:51:02] Nor had to use time I didn't have in my course schedule [16:51:16] i just watched a couple yt tutorials to learn java in 2019, and learned php by contributing to mediawiki in 2024 [16:51:18] I'm just not experinced in being very neat and tidy at this point [16:51:38] I never read a php tutorial or sth like that lol [16:51:41] I started coding with a python tutorial on freecodecamp.org to make discord bots [16:51:49] In like, 22 or smt [16:52:29] (as a side effect of that, I wouldn't be able to develop a proper standalone PHP app easily without looking at docs for a while) [16:52:37] all I know is MW stuff [16:53:02] ditto [16:58:26] Anyhow thanks @abaddriverlol for the feedback lol [17:01:05] [1/2] I don’t know time if I want to put in the time to set up a local dev env today (I still have to get off my ass and study some today but want to get this done sooner than later before the ADHD strikes) but I’ll clean up the rest and put it up on a draft PR. For the extension functions bit I’ll think if there’s an alternative but given the need is to push the hook load back I think any [17:01:05] [2/2] thing else I could do to accomplish that would be a lot hackier and more fragile (given the order in which we load extensions in our config) [17:05:38] You have to click on the file name to see it as text. Doesn't preview. [17:06:19] Click on the patch and then FXXX in the top left [17:06:31] Is dumb [17:11:30] docker runs on wsl2 on windows anyway [17:17:13] oh right [17:20:07] it's so good for company laptops [17:20:22] can run stuff without begging IT [17:21:56] Good to know [17:22:22] Though I really would rather just run Fedora, Microsoft and ARM, aren’t very friendly [17:28:47] I'm fairly sure our IT will block docker [17:30:23] Yeah it wasn't easy to get approval [17:30:36] Docker needs IT to give admin perms to `docker-users` group [18:16:53] What about podman since it doesn’t require root [18:17:45] Our IT block anything interesting outside of developer machines not connected to corporate [18:35:50] [1/12] ```php [18:35:51] [2/12] / @inheritDoc */ [18:35:51] [3/12] public function onUserGetRights($user, &$rights) [18:35:51] [4/12] { [18:35:52] [5/12] if (in_array('editallcustomprotected', $rights)) { [18:35:52] [6/12] $config = MediaWikiServices::getInstance()->getMainConfig(); [18:35:52] [7/12] $levels = $config->get('RestrictionLevels'); [18:35:52] [8/12] $toAdd = array_diff($levels, ['', 'user', 'autoconfirmed', 'sysop']); [18:35:53] [9/12] $rights = array_unique(array_merge([$rights, $toAdd])); [18:35:53] [10/12] } [18:35:53] [11/12] }``` [18:35:54] [12/12] thats a lot nicer lol [18:36:23] now it only needs to adhere to the mw coding style conventions :p [18:37:07] oh also it should use MainConfigNames instead of a string literal [19:03:39] Well yes, this wasn’t run through PHPCS or anything yet [19:03:50] What /genq [19:05:03] because it's always better to use constants instead of hardcoded strings [19:05:11] and it's commonly done this way [19:07:37] [1/2] the most obvious advantages are avoiding typos and being a single source of truth [19:07:38] [2/2] readability in some cases [19:07:47] yup [19:07:48] If you can give me a sample of that being done somewhere I’ll gladly integrate [19:08:04] just use MainConfigNames::RestrictionLevels [19:08:53] [19:09:30] wrong one [19:09:35] needs the core one [19:09:49] [19:09:50] hence MainConfigNames [19:10:06] didnt backread and didnt care 😎 [19:10:46] you get that on weekdays [19:12:35] Thanks friends [22:53:46] https://github.com/miraheze/MirahezeMagic/pull/650 Draft PR [23:27:26] I'm not quite sure how, but somehow this managed to break my ability to use GlobalGroupRights and GlobalGroupPermissions [23:28:21] did they eat your 2FA or something [23:30:14] No, I probably messed up on the rights logic [23:30:28] [1/9] ```php [23:30:28] [2/9] $rights = array_unique( [23:30:28] [3/9] array_merge( [23:30:29] [4/9] [ [23:30:29] [5/9] $rights, [23:30:29] [6/9] $toAdd [23:30:30] [7/9] ] [23:30:30] [8/9] ) [23:30:30] [9/9] );``` [23:30:33] commenting this out fixed it [23:32:51] remove the `[` and `]` in array_merge [23:32:56] otherwise you're passing a singular array to it [23:33:29] aaaaaah, I must have misread the docs [23:33:49] [1/2] I understood this as it taking an array with arrays as a value [23:33:49] [2/2] https://cdn.discordapp.com/attachments/1006789349498699827/1495568131224113332/image.png?ex=69e6b7dc&is=69e5665c&hm=064592215537cf29defb7f4c974576403ed734df1f22baea926f7132889ce35e& [23:33:50] which [23:33:53] thinking now [23:33:56] is stupid [23:34:03] That's the varargs syntax [23:34:04] but this is PHP so I don't feel bad [23:34:07] no, if there's a `...` in front of the name, it takes multiple of the defined type [23:34:17] (or none) [23:34:31] Oh! Useful context, thanks! [23:34:41] Also since you're on newer PHP I'm pretty sure you can use `[...$array1, ...$array2]` instead of `array_merge($array1, $array2)`? [23:35:27] I've never seen that being used in MW code tbh [23:35:59] only 9 times lol [23:36:10] It's from 7.x apparently [23:37:40] [1/3] Lol? [23:37:40] [2/3] https://cdn.discordapp.com/attachments/1006789349498699827/1495569100016193607/image.png?ex=69e6b8c3&is=69e56743&hm=27282361883bd632fe500e266fee2cb264f150c4489570d09fd24c05380953ef& [23:37:40] [3/3] https://cdn.discordapp.com/attachments/1006789349498699827/1495569100242550884/image.png?ex=69e6b8c3&is=69e56743&hm=a5f49c78d772a5941ffd271c60534115b51e3ccf67f56ab8132d57df47716c1a& [23:38:00] Useful to know, but for now I'd rather stick with the more clear/sstandard syntax, but I do appreicate the drop Kocka :Heart: [23:39:13] 🤝 [23:39:15] Worked [23:40:14] Pushed to the PR [23:43:42] I think that's everything you left before, minus the reconsideration of EF, but frankly I think I standby this being the least hacky and best solution under the current implementation [23:45:47] Ideally I'd want to test it more but, like, there isn't a whole lot to test [23:46:32] I may just mark the PR as ready for review [23:47:07] Well, first, appease phpcs [23:47:10] in theory you could add a unit test [23:47:29] baby's first test [23:47:42] (I have like never written unit tests in any lang before LOL) [23:48:13] I mean, you could probably check `CentralAuthUser::getInstance( $user )->hasGlobalPermission( 'example' )` in the hook, since the user instances are cached and the user is going to be loaded at some point during the request anyway, so it shouldn't really have a negative performance impact [23:48:29] And then register the hook the intended way