Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36906 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67690 invoked from network); 9 Apr 2008 15:43:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Apr 2008 15:43:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:56232] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/20-64512-4B3ECF74 for ; Wed, 09 Apr 2008 11:41:42 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id EE3C8C10911; Wed, 9 Apr 2008 08:41:35 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-4-101.neb.res.rr.com [76.84.4.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id B9192C1090F; Wed, 9 Apr 2008 08:41:34 -0700 (MST) Message-ID: <47FCE3B0.5090004@chiaraquartet.net> Date: Wed, 09 Apr 2008 10:41:36 -0500 User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: Steph Fox CC: Lars Strojny , php-dev , Marcus Boerger References: <47ED6D97.3030109@chiaraquartet.net> <1206788577.3621.15.camel@localhost> <47EEC989.5020603@chiaraquartet.net> <1206839984.3621.71.camel@localhost> <47FC4A83.6080205@chiaraquartet.net> <009c01c89a24$4d88f2e0$4001a8c0@foxbox> In-Reply-To: <009c01c89a24$4d88f2e0$4001a8c0@foxbox> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [PHP-DEV] practical phar considerations From: greg@chiaraquartet.net (Gregory Beaver) Steph Fox wrote: > Hi Greg, > >> What I would like to do, however, is to rethink offsetSet(). I think >> that we should introduce a property of PharFileInfo called "content" >> that is read/write, and can be used to perform the equivalent of >> file_get_contents()/file_put_contents(). This will allow a consistency >> that is much more intuitive. offsetSet() could then simply be removed, >> or perhaps be refactored as a way to pass in a PharFileInfo and clone >> the information. > > Could you offer up some pseudo-code showing how this will be used? I > can't visualize it at all from that description. I should have done this in the original post, because it turns out that it would require offsetGet() to implicitly create the file, which brings me back to my original objection to these changes. I'm adding in getContents() right now to retrieve the file contents into a string, so one can do: getContents(); ?> The truth is, I think offsetSet() could accept either a string/fp (file contents) or a PharFileInfo() that can be used to set a slew of things: - metadata - per-file compression - file contents This would also be relatively trivial to implement. >> One problem with this suggestion is that phar renames the archive by >> default when compressing. I would rather we combine compression and >> format conversion into a single convert() method that accepts constants. >> >> $phar = new Phar('blah.phar'); >> $phar = $phar->convert(Phar::GZ); // compress with gzip >> $phar = $phar->convert(Phar::TAR | PHAR::GZ); // convert to .phar.tar.gz >> $phar = $phar->convert(Phar::NONE | PHAR::DATA); // convert to >> non-executable .tar, returns PharData object >> $phar = $phar->convert(Phar::EXE); // convert back to .phar.tar > > Didn't we just go full circle here? There was a proposed convert() > method that did absolutely everything (on e-paper) and it was far less > intuitive than when conversion was separated from compression. That's > why you ended up implementing them separately, as I recall. It does look similar, but the key difference here is that convert() was a method that changed the underlying object. If we return a new object, this is a completely different ballpark, the current implementation actually can remain the same and remove the intermediary files. >> This would also solve a subtle but important problem with the current >> conversion API where intermediary files are lying around. > > Can't we simply delete those intermediary files on success? That would > be the normal procedure when renaming, no? Actually, no. The current implementation has no modification to the original file on disk, as there is no way to know in advance if the user actually intended to erase it, and it is actually impossible to do so if there are any open references to the archive (i.e. Phar objects or stream fp's lying around). >>>> Do you want to take a crack at a patch for any of these API features >>>> once they are worked out (buildFromDirectory should be an easy one, if >>>> you would like to start there)? >>> >>> Yes, I'm willing to help with it to a degree, as I said in a previous >>> mail. >> >> How soon can we expect a patch for this? Steph also expressed interest, >> and we are on a rather tight time schedule to get this to beta, which >> will mean a feature freeze (no new crap, just bug fixes). > > I'll implement buildFromDirectory() this weekend. It would've been last > weekend, but I got caught up in trying to bring the last few non-core > PECL modules into line over versioning structure, which hasn't been > entirely plain sailing. (Still 5 + IBM to go.) OK. Greg