Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130261 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id DC20F1A00BC for ; Thu, 5 Mar 2026 23:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1772755049; bh=dzrBcbUaSDEWZOu2AsRfsxrdL3rGYkSlS3yQ1jlrigk=; h=Date:To:From:Subject:From; b=JU+60D/uF8InEG6QU28ykwHyPNrG6zH3TK7djf6RDfHhjqpeU/+Fu+URFVjECF/bc C8giwb0Dv8DnGwnhpLZ9oxVZEfzqMQ/nlPp3CLgeL++qVpmLdSLFjhbWhKFot+uqiv KVasyZIE1jf2HRWbhFlSm2mF2GO34nwpXuzuWVTa8CvxhoQahqqexQKmhlQqImuQVR J1Xt6BlrABuQl6r/0ZADz+6uIqZLypsiCKwYL2iWK+84G8yHMDV7ztFak2AHwll3rU lsFeSuC5QQL4Y8TvPEkyTk/hcYC3s0jCYFg98Kh30UAUTZR742az6pSAb14/O5yrMk EXu99aLVSZucw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 32EEA180084 for ; Thu, 5 Mar 2026 23:57:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 5 Mar 2026 23:57:27 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-82735a41920so3326708b3a.2 for ; Thu, 05 Mar 2026 15:57:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wikimedia.org; s=google; t=1772755042; x=1773359842; darn=lists.php.net; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=AAlZZ9O0zh7UZB9uJ6MEpgEHB9T786RseAOjsXJ9bLY=; b=reXGXdtIXKUdeTPdh6lfBBWIjqI8TfyHoN78aq9EDxr2t8l4pjFeJtY0whV03GdZo8 ZWfQzCsnCpLkQLJBSV3vGMTvdXCJUEWwJlQ22N6CDlRiV/Zu/gN6gT2eB0IfipW7ANnR XXwSTjjnxpaRji5ARBQXqpp8HGCStP/KdtJlU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772755042; x=1773359842; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AAlZZ9O0zh7UZB9uJ6MEpgEHB9T786RseAOjsXJ9bLY=; b=FDarMz76BKrkJ6fw6Ehp/eoIwuXmP65F47gs8SQwbjOSJ6xbFzTkRcfDBldfnySSnx bzAxs56PlJ+OZAxlZDR6k/EQFyrC43NtGn2vZOTho4hzAwKxyQ931OESAijd1zv3tKQR vE7kcfdbCouXxL9w4N8CXDHITeZZRu8EecD5UFeJMWxijDWiD/CDypzDoydmgdfyg5Rt Mb2wMpfE9mpc2EnPIz3xuWd06G9Jqqh2mptw9Y//Ky9YipIDrIiTap2cbqzqqTPEPd4P L6G4nTi+B2+Q4JGYe6Vi14UXctasr2bk6AIx785vDB+ECXqi6CuAWEjJhS74B1nY9WeG j4+g== X-Gm-Message-State: AOJu0YxFJDWcrKZBtiYuoTQUo6ZOx3S+EYVnd8rBBS+QsXQbnSMLHLzB AkAdw3YBlskp530nYdqInNP2H0cq9naA10B6B6W4rp2cMlunYm9Z2jYO3FZAaNI8zS+Wg08XjN3 RUYtw X-Gm-Gg: ATEYQzycAvB6NR5amBFGdfo3AIw5SsSLONhGIDVTMDx99fGZ4n6aVIztuYPNWcuJY1i I2al9Ka7nRluoWIUp/Jq9ZTZJPevznkUcXqVWWoUgRCeedeh4w07ujNqJ2mBVolhjnq71Clckz3 02huwCQXFG7ItzGOqP8AaR3B6+DhJ4UoRIgJ/ERxG49yOcGpFKWrGKPjCoP7kD+GLV/tPnwu8hZ qiurXA+MDcnq0jUapCrvJmD0b8qhwZtYaMnjXvxRlpVig9C7rQTaJaaeiNUUz9RNWU/ussisl8b ha4iVzAO+2Uqc7sm9fCnPj+WRKYFM8nH/fZE5wgVNy39YmEdgc/rAJsgLMG3yzlbqCGYWOTJXNt R/5fIMJWwyG497XT4unJ8okSDy5LtI7soC0qUHIrKYJsliEJP7rDTiQn3vAF27vCe5I1pX1fqrZ 4IpaWBkCJHwVpg+DA5BTwa20ZWIb1l9AzY3EFS5d3yZPmc1A2XtzAL5joG+n739WGeUAwjIspwT k5zTRVEZH2Urwe7WLhp9TlSQCSjzicNm4OGaqniltagu0pyLL09OiH17A== X-Received: by 2002:a05:6a00:9287:b0:81f:17b:c70f with SMTP id d2e1a72fcca58-829a2e18916mr103218b3a.29.1772755041283; Thu, 05 Mar 2026 15:57:21 -0800 (PST) Received: from ?IPV6:2403:5809:37b3:0:998:fd39:2299:428b? (2403-5809-37b3-0-998-fd39-2299-428b.ip6.aussiebb.net. [2403:5809:37b3:0:998:fd39:2299:428b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8298e640d6esm3195636b3a.52.2026.03.05.15.57.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2026 15:57:20 -0800 (PST) Message-ID: Date: Fri, 6 Mar 2026 10:57:15 +1100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: internals@lists.php.net Content-Language: en-US Subject: [PHP-DEV] ext/zip: ZipArchive::openString and other improvements Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tstarling@wikimedia.org (Tim Starling) I have a PR open to add ZipArchive::openString(): https://github.com/php/php-src/pull/21205 This is a fork of a 2024 pull request by Soner Sayakci. I found the old pull request and figured it could benefit from a bit of enthusiasm, to get it over the line and into PHP. ext/zip doesn't currently have a maintainer. It's been challenging to find someone willing to hit the merge button. Nora Dossche provided a much-needed review, and might eventually merge it, but they also suggested that I post here, to see if anyone else is willing to take it on. The usual syndrome with PHP pull requests is that there are plenty of people available for drive-by nitpicks, but nobody who really wants to take responsibility. The nitpicks contradict each other so I have to figure out who is serious about doing the merge. If you're just passing by, I feel like I can respectfully disagree, but if you have your finger on the merge button, I'll write it whatever way you want. In comments on the PR I've outlined a plan for future improvements to ext/zip which I'll relate here. The current PR adds ZipArchive::openString(), which takes a single parameter, being a ZIP archive stored in a string. It opens the archive in read-only mode. I think it can be merged alone, it's sufficiently forwards-compatible. I've suggested that in future we could add a $flags parameter to ZipArchive::openString(), by analogy with ZipArchive::open(), allowing the user to choose whether the archive is read-only or read/write. For consistency with ZipArchive::open(), it would be read/write by default. Then we would add ZipArchive::closeToString(), which would provide access to the updated string. The read-only restriction in the current patch is the result of using zip_source_buffer_create(), which takes a pointer to the string data. But zip_source_buffer_create() is implemented as a wrapper around zip_source_function_create(), a callback interface. If we call zip_source_function_create() directly, we can separate and reallocate the underlying zend string when libzip makes a write request. Using the callback interface, we could also implement ZipArchive::openStream(), that is, opening a ZIP file stored in a seekable stream resource. You could open a ZIP stored inside a ZIP this way: $zip2->openStream( $zip1->getStream( 'file.zip' ) ); It also answers my own use case which is opening zip files in the php://temp streams used by Guzzle for HTTP response bodies. We could even reimplement ZipArchive::open() using the same mechanism, using PHP to open the file and then wrapping the stream for libzip to directly read. This would solve a long-standing request to allow ZipArchive::open() to use stream protocols. The difficulty with this is maintaining backwards compatibility with ext/zip's highly idiosyncratic error reporting scheme. -- Tim Starling Wikimedia Foundation