Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P9485
RL hashed module names test script
Active
Public
Actions
Authored by
hoo
on Oct 27 2019, 8:33 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F30900442: raw.txt
Oct 27 2019, 8:33 AM
2019-10-27 08:33:09 (UTC+0)
Subscribers
None
#!/bin/env php
<?php
$fileName
=
$argv
[
1
];
$origStartup
=
file_get_contents
(
$fileName
);
$start
=
'mw.loader.register(['
;
$end
=
']);'
;
$moduleSectionStart
=
strpos
(
$origStartup
,
$start
)
+
strlen
(
$start
)
-
1
;
$moduleSectionEnd
=
strpos
(
$origStartup
,
$end
,
$moduleSectionStart
+
1
)
+
1
;
$preModuleSection
=
substr
(
$origStartup
,
0
,
$moduleSectionStart
);
$moduleSection
=
substr
(
$origStartup
,
$moduleSectionStart
,
(
$moduleSectionEnd
-
$moduleSectionStart
)
);
$postModuleSection
=
substr
(
$origStartup
,
$moduleSectionEnd
);
$modules
=
json_decode
(
$moduleSection
);
$moduleSection
=
json_encode
(
$modules
);
$hashedModules
=
[];
foreach
(
$modules
as
$module
)
{
$hashedModules
[]
=
[
substr
(
md5
(
$module
[
0
]
),
0
,
5
),
array_slice
(
$module
,
1
)
];
}
$hashedModuleSection
=
json_encode
(
$hashedModules
);
file_put_contents
(
$fileName
.
'-no-new-lines'
,
$preModuleSection
.
$moduleSection
.
$postModuleSection
);
file_put_contents
(
$fileName
.
'-no-new-lines-hashed-module-names'
,
$preModuleSection
.
$hashedModuleSection
.
$postModuleSection
);
Event Timeline
hoo
created this paste.
Oct 27 2019, 8:33 AM
2019-10-27 08:33:09 (UTC+0)
hoo
mentioned this in
T236609: Consider using hashed module names in RL startup module
.
Oct 27 2019, 8:37 AM
2019-10-27 08:37:02 (UTC+0)
Log In to Comment