Skip to content

Commit 8614d95

Browse files
committed
Drop pear PHP_Archive support from Phar
1 parent 1a50bfe commit 8614d95

File tree

10 files changed

+20
-224
lines changed

10 files changed

+20
-224
lines changed

ext/phar/Makefile.frag

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ PHP_PHARCMD_EXECUTABLE = ` \
2525
fi;`
2626
PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";`
2727

28-
$(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc
29-
-@test -d $(builddir)/phar || mkdir $(builddir)/phar
30-
-@test -f $(builddir)/phar/phar.inc || cp $(srcdir)/phar/phar.inc $(builddir)/phar/phar.inc
31-
3228
TEST_PHP_EXECUTABLE = $(shell $(PHP_EXECUTABLE) -v 2>&1)
3329
TEST_PHP_EXECUTABLE_RES = $(shell echo "$(TEST_PHP_EXECUTABLE)" | grep -c 'Exec format error')
3430

ext/phar/phar.1.in

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ Subscription \fIindex\fP to work on.
249249
Pack files into a PHAR archive.
250250
.P
251251
When using -s <stub>, then the stub file is being excluded from the
252-
list of input files/dirs.To create an archive that contains PEAR class
253-
PHP_Archive then point -p argument to PHP/Archive.php.
252+
list of input files/dirs.
254253
.P
255254
Required arguments:
256255
.TP 15
@@ -300,16 +299,7 @@ Number of preceding subdirectories to strip from file entries
300299
.TP
301300
.PD
302301
.B \-p \fIloader\fP
303-
Location of PHP_Archive class file (pear list-files
304-
PHP_Archive).You can use '0' or '1' to locate it
305-
automatically using the mentioned pear command. When
306-
using '0' the command does not error out when the class
307-
file cannot be located. This switch also adds some code
308-
around the stub so that class PHP_Archive gets
309-
registered as phar:// stream wrapper if necessary. And
310-
finally this switch will add the file phar.inc from
311-
this package and load it to ensure class Phar is
312-
present.
302+
Ignored option for PHP_Archive which is no longer supported.
313303
.TP
314304
.PD
315305
.B \-s \fIstub\fP
@@ -380,16 +370,8 @@ The hash mark itself '#!' and the newline character are optional.
380370
.TP
381371
.PD
382372
.B \-p \fIloader\fP
383-
Location of PHP_Archive class file (pear list-files
384-
PHP_Archive).You can use '0' or '1' to locate it
385-
automatically using the mentioned pear command. When
386-
using '0' the command does not error out when the class
387-
file cannot be located. This switch also adds some code
388-
around the stub so that class PHP_Archive gets
389-
registered as phar:// stream wrapper if necessary. And
390-
finally this switch will add the file phar.inc from
391-
this package and load it to ensure class Phar is
392-
present.
373+
This option no longer works. It used to be used for PHP_Archive which
374+
is no longer supported.
393375
.TP
394376
.PD
395377
.B \-s \fIstub\fP

ext/phar/phar.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,8 +3452,6 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
34523452
php_info_print_table_end();
34533453

34543454
php_info_print_box_start(0);
3455-
PUTS("Phar based on pear/PHP_Archive, original concept by Davey Shafik.");
3456-
PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
34573455
PUTS("Phar fully realized by Gregory Beaver and Marcus Boerger.");
34583456
PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
34593457
PUTS("Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.");

ext/phar/phar/phar.inc

Lines changed: 0 additions & 80 deletions
This file was deleted.

ext/phar/phar/phar.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,8 @@
1212

1313
if (!extension_loaded('phar'))
1414
{
15-
if (!class_exists('PHP_Archive', 0)) {
16-
echo "Neither Extension Phar nor class PHP_Archive are available.\n";
17-
exit(1);
18-
}
19-
if (!in_array('phar', stream_get_wrappers())) {
20-
stream_wrapper_register('phar', 'PHP_Archive');
21-
}
22-
if (!class_exists('Phar',0)) {
23-
require 'phar://'.__FILE__.'/phar.inc';
24-
}
15+
echo "Phar Extension is not loaded.\n";
16+
exit(1);
2517
}
2618

2719
foreach(array("SPL", "Reflection") as $ext)

ext/phar/phar/pharcommand.inc

Lines changed: 12 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,8 @@ class PharCommand extends CLICommand
117117
'p' => array(
118118
'typ' => 'loader',
119119
'val' => NULL,
120-
'inf' => '<loader> Location of PHP_Archive class file (pear list-files PHP_Archive).'
121-
.'You can use \'0\' or \'1\' to locate it automatically using the mentioned '
122-
.'pear command. When using \'0\' the command does not error out when the '
123-
.'class file cannot be located. This switch also adds some code around the '
124-
.'stub so that class PHP_Archive gets registered as phar:// stream wrapper '
125-
.'if necessary. And finally this switch will add the file phar.inc from '
126-
.'this package and load it to ensure class Phar is present.'
120+
'inf' => '<loader> Used to be used for PHP_Archive class file which is no longer '
121+
.'supported.'
127122
,
128123
),
129124
's' => array(
@@ -213,53 +208,11 @@ class PharCommand extends CLICommand
213208
static function cli_arg_typ_loader($arg, $cfg, $key)
214209
{
215210
if (($arg == '0' || $arg == '1') && !file_exists($arg) && substr(PHP_OS, 0, 3) != 'WIN') {
216-
$found = NULL;
217-
$apiver = false;
218-
$path = explode(PATH_SEPARATOR, $_ENV['PATH']);
219-
$pear = false;
220-
foreach ($path as $component) {
221-
if (file_exists($component . DIRECTORY_SEPARATOR . 'pear')
222-
&& is_executable($component . DIRECTORY_SEPARATOR . 'pear')) {
223-
$pear = true;
224-
break;
225-
}
226-
}
227-
if ($pear) {
228-
$apiver = (string) shell_exec("pear -q info PHP_Archive 2>/dev/null|grep 'API Version'");
229-
$apiver = trim(substr($apiver, strlen('API Version')));
230-
}
231-
if ($apiver) {
232-
self::notice("PEAR package PHP_Archive: API Version: $apiver.\n");
233-
$files = explode("\n", (string) shell_exec("pear list-files PHP_Archive"));
234-
$phpdir = (string) shell_exec("pear config-get php_dir 2>/dev/null");
235-
$phpdir = trim($phpdir);
236-
self::notice("PEAR package PHP_Archive: $phpdir.\n");
237-
if (is_dir($phpdir)) {
238-
foreach($files as $ent) {
239-
$matches = NULL;
240-
if (preg_match(",^php[ \t]+([^ \t].*[\\\\/]PHP[\\\\/]Archive\.php)$,", $ent, $matches)) {
241-
$sub = $matches[1];
242-
if (strpos($sub, $phpdir) !== 0) {
243-
$found = NULL;
244-
break;
245-
}
246-
$found = $sub;
247-
break;
248-
}
249-
}
250-
} else {
251-
self::notice("PEAR package PHP_Archive: corrupt or inaccessible base dir: $phpdir.\n");
252-
}
253-
}
254-
if (isset($found)) {
255-
self::notice("PEAR package PHP_Archive: $found.\n");
211+
$msg = "PEAR package PHP_Archive is no longer supported: generated phar requires PHP's phar extension enabled\n";
212+
if ($arg == '0') {
213+
self::notice($msg);
256214
} else {
257-
$msg = "PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.\n";
258-
if ($arg == '0') {
259-
self::notice($msg);
260-
} else {
261-
self::error($msg);
262-
}
215+
self::error($msg);
263216
}
264217
return null;
265218
}
@@ -454,9 +407,7 @@ class PharCommand extends CLICommand
454407
{
455408
return "Pack files into a PHAR archive.\n" .
456409
"When using -s <stub>, then the stub file is being " .
457-
"excluded from the list of input files/dirs." .
458-
"To create an archive that contains PEAR class PHP_Archive " .
459-
"then point -p argument to PHP/Archive.php.\n";
410+
"excluded from the list of input files/dirs.\n";
460411
}
461412
// }}}
462413
// {{{ static function cli_cmd_arg_pack
@@ -483,7 +434,7 @@ class PharCommand extends CLICommand
483434
/**
484435
* Set the stub
485436
*/
486-
public function phar_set_stub_begin(Phar $phar, $stub, $loader = NULL, $hashbang = NULL)
437+
public function phar_set_stub_begin(Phar $phar, $stub, $hashbang = NULL)
487438
{
488439
if (isset($stub)) {
489440
$c = file_get_contents($stub);
@@ -512,46 +463,12 @@ class PharCommand extends CLICommand
512463
} else {
513464
$hashbang = "";
514465
}
515-
516-
if (isset($loader)) {
517-
$s = "<?php if (!class_exists('PHP_Archive')) {\n?>";
518-
if (is_file($loader)) {
519-
$s .= file_get_contents($loader);
520-
}
521-
$s .= "<?php\n";
522-
$s .= "}\n";
523-
$s .= "if (!in_array('phar', stream_get_wrappers())) {\n";
524-
$s .= "\tstream_wrapper_register('phar', 'PHP_Archive');\n";
525-
$s .= "}\n";
526-
$s .= "if (!class_exists('Phar',0)) {\n";
527-
$s .= "\tinclude 'phar://'.__FILE__.'/phar.inc';\n";
528-
$s .= "}\n";
529-
$s .= '?>';
530-
$s .= $c;
531-
532-
$phar->setStub($hashbang . $s);
533-
} else {
534466
$phar->setStub($hashbang . $c);
535-
}
536467
return new SplFileInfo($stub);
537468
}
538469
return NULL;
539470
}
540471
// }}}
541-
// {{{ function phar_set_stub_end
542-
/**
543-
* Set stub end
544-
*/
545-
public function phar_set_stub_end(Phar $phar, $stub, $loader = NULL)
546-
{
547-
if (isset($stub) && isset($loader)) {
548-
if (substr(__FILE__, -15) == 'pharcommand.inc') {
549-
self::phar_add_file($phar, 0, 'phar.inc', 'phar://'.__FILE__.'/phar.inc', NULL);
550-
} else {
551-
self::phar_add_file($phar, 0, 'phar.inc', dirname(__FILE__).'/phar/phar.inc', NULL);
552-
}
553-
}
554-
}
555472
// }}}
556473
// {{{ function cli_cmd_run_pack
557474
/**
@@ -578,7 +495,6 @@ class PharCommand extends CLICommand
578495
$privkey = $this->args['y']['val'] ?? null;
579496
$regex = $this->args['i']['val'];
580497
$level = $this->args['l']['val'];
581-
$loader = $this->args['p']['val'];
582498
$stub = $this->args['s']['val'];
583499
$invregex = $this->args['x']['val'];
584500
$input = $this->args['']['val'];
@@ -599,8 +515,6 @@ class PharCommand extends CLICommand
599515
}
600516
}
601517

602-
$this->phar_set_stub_end($phar, $stub, $loader);
603-
604518
switch($this->args['c']['val']) {
605519
case 'gz':
606520
case 'gzip':
@@ -685,9 +599,9 @@ class PharCommand extends CLICommand
685599
$entry = substr($entry, $p+1);
686600
}
687601

688-
if ($noloader && $entry == 'phar.inc') {
689-
return;
690-
}
602+
if ($noloader && $entry == 'phar.inc') {
603+
return;
604+
}
691605

692606
echo "$entry\n";
693607

@@ -1063,10 +977,8 @@ class PharCommand extends CLICommand
1063977
$hashbang = $this->args['b']['val'];
1064978
$phar = $this->args['f']['val'];
1065979
$stub = $this->args['s']['val'];
1066-
$loader = $this->args['p']['val'];
1067980

1068-
$this->phar_set_stub_begin($phar, $stub, $loader, $hashbang);
1069-
$this->phar_set_stub_end($phar, $stub, $loader);
981+
$this->phar_set_stub_begin($phar, $stub, $hashbang);
1070982
}
1071983
// }}}
1072984
// {{{ public function cli_cmd_inf_stub_get

ext/phar/tests/phpinfo_001.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ bzip2 compression => enabled
3333
OpenSSL support => disabled (install ext/openssl)
3434

3535

36-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.
3736
Phar fully realized by Gregory Beaver and Marcus Boerger.
3837
Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
3938
Directive => Local Value => Master Value
@@ -53,7 +52,6 @@ bzip2 compression => enabled
5352
OpenSSL support => disabled (install ext/openssl)
5453

5554

56-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.
5755
Phar fully realized by Gregory Beaver and Marcus Boerger.
5856
Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
5957
Directive => Local Value => Master Value

ext/phar/tests/phpinfo_002.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ bzip2 compression => enabled
3131
OpenSSL support => disabled (install ext/openssl)
3232

3333

34-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.
3534
Phar fully realized by Gregory Beaver and Marcus Boerger.
3635
Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
3736
Directive => Local Value => Master Value

ext/phar/tests/phpinfo_003.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ bzip2 compression => disabled (install ext/bz2)
3131
OpenSSL support => disabled (install ext/openssl)
3232

3333

34-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.
3534
Phar fully realized by Gregory Beaver and Marcus Boerger.
3635
Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
3736
Directive => Local Value => Master Value

ext/phar/tests/phpinfo_004.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ phpinfo(INFO_MODULES);
3838
</table>
3939
<table>
4040
<tr class="v"><td>
41-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
41+
Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
4242
</table>
4343
<table>
4444
<tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr>
@@ -60,7 +60,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full
6060
</table>
6161
<table>
6262
<tr class="v"><td>
63-
Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
63+
Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
6464
</table>
6565
<table>
6666
<tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr>

0 commit comments

Comments
 (0)