Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114528 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94456 invoked from network); 20 May 2021 08:35:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 May 2021 08:35:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 30D8F18050A for ; Thu, 20 May 2021 01:45:45 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 May 2021 01:45:44 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id s5-20020a7bc0c50000b0290147d0c21c51so4701221wmh.4 for ; Thu, 20 May 2021 01:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=4mQtu45/6ABB7JMD5xNkds/sQLOHRYTddZ1+zzn/AjQ=; b=A+o5VU24mbaBvgiWDuXOw6klObVHqnGGCcv/2cabHVZiSV+PC0RtzoGHy5wM5V4EXm 2GfRqkxtVPtsxqUPm9N2hhjm38l5M//ytMKMatyno+OceWh4rdh0nj2LYpDteTbTxnUS RR4oUIgA8dy+krA/cK0HOfc0dhYA1p707ASEVCOD3hUl6ghStV6c7KMIm2XimP9zQhwQ tOfEA533MrfdCIgRMYebdz70dsq4kNVW0r9AH/5MQdyqu/3zFfO8WKjz3CJlkM4aP6I/ TCtOhZggV19U1CYe1O6NRzbb0tNmqAtQwEpNCRnxJ3Z5vkWhcI6Dh/7X6IxNVklNTnGE ZfBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=4mQtu45/6ABB7JMD5xNkds/sQLOHRYTddZ1+zzn/AjQ=; b=SSix0WYsdHyQZESX3/sxbjl/vJgj1w2QI/mveeIcDfW6fh0m5Vwf++ts5mDjFfRVK+ 3rm/+rXMq1ctFSg7draeuNiBCGpYpm5CPU0uFaQL6Ox0mmW/9F4PFs+VQR25x+a3/Y0Z 3u5wAqgSSf4dC99fiIlNUCLmP0BrcLKn3owb4Mvgn14K8t04U/3uCteRDYra4KVbG1eP MY7Rkz2MV6/1ulLkVuGc2d6/58C0VIvIvdJ2nX/atQGDDtWk6l7DQGjRZZE7gPCXn6ap rjQEr2u/CUpaA2Xerl8DMuDADSlGgIhyc2XMmSrTfSy1Yo20uIMjwEyHH8u4T8qTXVMo q8OQ== X-Gm-Message-State: AOAM532hb192SOOEtiXua3muByL0sSwYlqtgK2awmL5PDddaNTGtTqV4 Hvr8AW+AtxI5Y1lmCoxO5rIwPiTOE1I= X-Google-Smtp-Source: ABdhPJzsqf5fsSu6hyPXc6IdhymMsq+yyMsZp4Pgx6f5Br/28Jhz46bNeqj1+FPgB5xv2bgMzof/dw== X-Received: by 2002:a7b:c114:: with SMTP id w20mr3001967wmi.45.1621500342723; Thu, 20 May 2021 01:45:42 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id n15sm2279396wrr.20.2021.05.20.01.45.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 May 2021 01:45:41 -0700 (PDT) To: PHP internals References: <72767cd7-ffc5-c84b-523c-123ff6ef30fa@gmail.com> Message-ID: Date: Thu, 20 May 2021 09:45:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] [Draft] Add RNG extension and deprecate mt_srand() From: rowan.collins@gmail.com (Rowan Tommins) On 20/05/2021 05:59, Go Kudo wrote: > Thanks. > > Deprecation will be done only to prevent unintended MT state dependent > code. We don't plan to go as far as removing the implementation for now. I think every deprecation notice should mean a plan to remove. If you just want to encourage people to discover the new functions, I'm not sure a message in their logs every time mt_srand runs is the right way to do it. > > Firstly, making these functions independent of mt_srand() is a > breaking change, so cannot happen until PHP 9.0 at the earliest. > > To be honest, I don't understand how far PHP is willing to go to > accept disruptive changes. The official policy is here: https://wiki.php.net/rfc/releaseprocess It relies on the phrase "backwards compatibility", which is admittedly quite hard to define. You are right that the change from using rand() to using mt_rand() in 7.1 is arguably not backwards compatible. However, the following code can be used to reproducibly shuffle two arrays in any version of PHP: srand(123456); shuffle($array1); shuffle($array2); The exact sequence returned will be different in 7.1 from 7.0, but because srand() is now an alias of mt_srand(), it still affects the shuffle() function in the expected way. If we switch shuffle() to an algorithm that can't be seeded at all, this code will simply stop working, and have to be completely rewritten. A "polyfill" of sorts is possible, by storing an instance of the new RNG\Randomizer in a global or static variable, but it's more than just a find-and-replace, especially since many users will need to support version 8.0 and 8.1 in the same code base. As I said previously, I'm not convinced these functions need to stop using the MT algorithm at all, and certainly see no reason to rush the change. Regards, -- Rowan Tommins [IMSoP]