Skip to content

Commit

Permalink
Merge branch 'php:master' into xinclude
Browse files Browse the repository at this point in the history
  • Loading branch information
alfsb authored Nov 27, 2024
2 parents dc20b4f + d53ce70 commit 79a06be
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 72 deletions.
6 changes: 6 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ or by fixing one by [submitting a pull request](#submit-a-pull-request).
As all the repositories are hosted on GitHub,
you will need a GitHub account to do either of these.

<a name="report-a-bug"></a>
## Report a Bug

If you have found a bug on any of the PHP documentation pages,
Expand All @@ -18,13 +19,15 @@ you can file a bug report by doing the following:
- add all necessary details to the description textarea
- click the "Submit new issue" button to file your bug report

<a name="submit-a-pull-request"></a>
## Submit a Pull Request

There are two ways to make changes to the documentation:
- make [minor changes](#minor-changes) by editing files on GitHub
- make [more complex changes](#more-complex-changes--building-the-php-documentation)
and validate/build the documentation locally on your computer

<a name="minor-changes"></a>
## Minor changes

To make trivial changes (typos, shorter wording changes or adding/removing short segments)
Expand All @@ -45,6 +48,7 @@ The repository will run a few basic checks on the changes
(e.g. whether the XML markup is valid, whether trailing whitespaces are stripped, etc.)
and your PR is ready to be discussed with and merged by the maintainers.

<a name="more-complex-changes--building-the-php-documentation"></a>
## More Complex Changes / Building the PHP documentation

To build and view the documentation after making more extensive changes
Expand All @@ -59,10 +63,12 @@ If you'd like to know more about what each repository is
and/or how PHP's documentation is built please refer to
the [overview](overview.md).

<a name="make-changes-to-the-documentation"></a>
### Make changes to the documentation

[Make your changes](editing.md) keeping in mind the [style guidelines](style.md).

<a name="commit-changes-and-open-a-pr"></a>
### Commit changes and open a PR

- commit your changes
Expand Down
8 changes: 7 additions & 1 deletion entities/global.ent
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<!ENTITY url.cldr.locale "http://www.unicode.org/cldr/">
<!ENTITY url.cloud.ec2 "http://aws.amazon.com/ec2/">
<!ENTITY url.cloud.ec2.sdk "http://aws.amazon.com/sdkforphp/">
<!ENTITY url.composer "https://getcomposer.org/">
<!ENTITY url.comspecs "https://docs.microsoft.com/windows/desktop/com/component-object-model--com--portal">
<!ENTITY url.com.visible "https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.comvisibleattribute">
<!ENTITY url.connectionstrings "http://www.connectionstrings.com/">
Expand Down Expand Up @@ -327,6 +328,9 @@
<!ENTITY url.oracle.taf.dbmsservice "https://www.oracle.com/pls/topic/lookup?ctx=dblatest&amp;id=GUID-C11449DC-EEDE-4BB8-9D2C-0A45198C1928">
<!ENTITY url.oracle.taf.clientconfig "https://www.oracle.com/pls/topic/lookup?ctx=dblatest&amp;id=GUID-8F532535-C401-4B51-BE0B-04FD74BB0621">
<!ENTITY url.oreilly.cjk-inf "https://resources.oreilly.com/examples/9781565922242/blob/master/doc/cjk.inf">
<!ENTITY url.packagist "https://packagist.org">
<!-- linking to specific packagist packages is done like so: &url.packagist.package;package_name -->
<!ENTITY url.packagist.package "https://packagist.org/packages/">
<!ENTITY url.password.compat "https://github.com/ircmaxell/password_compat">
<!ENTITY url.pcre.changelog "http://www.pcre.org/original/changelog.txt">
<!ENTITY url.pcre.man "http://www.pcre.org/pcre.txt">
Expand Down Expand Up @@ -403,7 +407,7 @@
<!ENTITY url.rec-xml "http://www.w3.org/TR/1998/REC-xml-19980210">
<!ENTITY url.relaxng "http://www.relaxng.org/">
<!-- linking to specific rfcs is done like so: &url.rfc;xxxx so for example &url.rfc;2042 -->
<!ENTITY url.rfc 'http://www.faqs.org/rfcs/rfc'>
<!ENTITY url.rfc "https://datatracker.ietf.org/doc/html/rfc">
<!ENTITY url.rnp "https://www.rnpgp.org/">
<!ENTITY url.iana.system-names 'http://www.iana.org/assignments/operating-system-names'>
<!ENTITY url.rpmfind "http://www.rpmfind.net/">
Expand Down Expand Up @@ -558,6 +562,8 @@
<!ENTITY link.superglobals '<link xmlns="http://docbook.org/ns/docbook" linkend="language.variables.predefined">superglobals</link>'>
<!ENTITY link.autoload '<link xmlns="http://docbook.org/ns/docbook" linkend="language.oop5.autoload">__autoload</link>'>

<!ENTITY link.composer '<link xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.pecl;">Composer</link>'>

<!ENTITY link.pecl '<link xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.pecl;">PECL</link>'>

<!ENTITY spec.strftime 'http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html'>
Expand Down
1 change: 1 addition & 0 deletions manual.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
&install.cloud.index;
&install.fpm.index;
&install.pecl;
&install.composer;
&install.ini;
</book>

Expand Down
2 changes: 1 addition & 1 deletion scripts/translation/genrevdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function generate( SQLite3 $db , string $lang )
}
catch ( Exception $e )
{
$db->exec( 'ROLLBACK TRANSACTION' );
consolelog( "Throw: " . $e->getMessage() );
$db->exec( 'ROLLBACK TRANSACTION' );
exit;
}
}
Expand Down
48 changes: 0 additions & 48 deletions scripts/translation/lib/GitDiffParser.php

This file was deleted.

136 changes: 136 additions & 0 deletions scripts/translation/lib/GitLogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,140 @@ static function parseInto( string $lang , RevcheckFileList & $list )

pclose( $fp );
}

static function parseDir( string $gdir , RevcheckFileList $list )
{
$gdir = escapeshellarg( $gdir );
$proc = new GitLogParserProc( "git -C $gdir log --name-only" );

$hash = "";
$date = "";
$skip = false;
$lcnt = 0;

while ( $proc->live )
{
// Hash

if ( str_starts_with( $proc->line , "commit " ) )
{
$hash = trim( substr( $proc->line , 7 ) );
$date = "";
$skip = false;
$lcnt = 0;
$proc->next();
}
else
throw new Exception( "Expected commit hash." );

// Headers

while ( $proc->live && strlen( trim( $proc->line ) ) > 0 )
{
// Date
if ( str_starts_with( $proc->line , 'Date:' ) )
{
$line = trim( substr( $proc->line , 5 ) );
$date = strtotime( $line );
$proc->next();
continue;
}
// Other headers
if ( $proc->line[0] != ' ' && strpos( $proc->line , ':' ) > 0 )
{
$proc->next();
continue;
}
break;
}

$proc->skip(); // Empty Line

// Message

while ( $proc->live && str_starts_with( $proc->line , ' ' ) )
{
if ( LOOSE_SKIP_REVCHECK ) // https://github.com/php/doc-base/pull/132
{
// Messages that contains [skip-revcheck] flags entire commit as ignored.
if ( str_contains( $proc->line , '[skip-revcheck]' ) )
$skip = true;
}
else
{
// Messages that start with [skip-revcheck] flags entire commit as ignored.
$lcnt++;
if ( $lcnt == 1 && str_starts_with( trim( $line ) , '[skip-revcheck]' ) )
$skip = true;
}
$proc->next();
}

$proc->skip(); // Empty Line

// Merge commits and empty files commits

// Merge commits are not followed with file listings.
// Some normal commits also not have file listings
// (see b73609198d4606621f57e165efc457f30e403217).

if ( str_starts_with( $proc->line , "commit " ) )
continue;

// Files

while ( $proc->live && strlen( trim( $proc->line ) ) > 0 )
{
$file = $list->get( trim( $proc->line ) );

if ( $file != null )
$file->addGitLogData( $hash , $date , $skip );

$proc->next();
}

$proc->skip(); // Empty Line
}
}
}

class GitLogParserProc
{
public bool $live;
public string $line;
private $proc = null;

function __construct( string $command )
{
$this->proc = popen( $command , "r" );
$this->live = true;
$this->next();
}

function next()
{
if ( $this->proc == null )
return;

$ret = fgets( $this->proc );
if ( $ret === false )
$this->stop();
else
$this->line = $ret;
}

function skip()
{
if ( trim( $this->line ) != "" )
throw new Exception( "Skipping non-blank line." );
$this->next();
}

function stop()
{
pclose( $this->proc );
$this->live = false;
$this->line = "";
$this->proc = null;
}
}
103 changes: 103 additions & 0 deletions scripts/translation/lib/GitSlowUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
# +----------------------------------------------------------------------+
# | Copyright (c) 1997-2024 The PHP Group |
# +----------------------------------------------------------------------+
# | This source file is subject to version 3.01 of the PHP license, |
# | that is bundled with this package in the file LICENSE, and is |
# | available through the world-wide-web at the following url: |
# | https://www.php.net/license/3_01.txt. |
# | If you did not receive a copy of the PHP license and are unable to |
# | obtain it through the world-wide-web, please send a note to |
# | license@php.net, so we can mail you a copy immediately. |
# +----------------------------------------------------------------------+
# | Authors: André L F S Bacci <ae php.net> |
# +----------------------------------------------------------------------+
# | Description: Common functions that interact with git command line. |
# +----------------------------------------------------------------------+

require_once __DIR__ . '/all.php';

class GitSlowUtils
{
public static function checkDiffOnlyWsChange( string $gdir , RevcheckDataFile $file ) : bool
{
$hash = $file->hashRvtg;
$flnm = $file->path == "" ? $file->name : $file->path . "/" . $file->name;

$gdir = escapeshellarg( $gdir );
$flnm = escapeshellarg( $flnm );
$hash = escapeshellarg( $hash );

$func = '[' . __CLASS__ . ':' . __FUNCTION__ . ']';

// Fast path

// The git -b option is a bit misleading. It will ignore ws change
// on existing ws runs, but will report insertion or remotion of
// ws runs. This suffices for detecting significant ws changes and
// also ignoring insignificant ws changes in most cases we are
// interessed.

$output = `git -C $gdir diff -b $hash -- $flnm`;
$onlyws = $output == "";

// Slow path

if ( $onlyws )
{
$prev = `git -C $gdir show $hash:$flnm )`;
$next = `git -C $gdir show HEAD:$flnm )`;

if ( $prev == "" || $next == "" )
{
fprintf( STDERR , "$func Failed to read file contents.\n" );
return $onlyws;
}

$prev = GitUtils::discardPrefixSuffixEmptyWs( $prev );
$next = GitUtils::discardPrefixSuffixEmptyWs( $next );

if ( $prev != $next )
{
// Not really an error, but a theory. Report this bug/issue
// to start a discussion if this ws change must be ignored
// or tracked.

fprintf( STDERR , "$func Debug: Fast and slow path differ.\n" );
return false;
}
}

return $onlyws;
}

private static function discardPrefixSuffixEmptyWs( string $text ) : string
{
$lines = explode( "\n" , $text );
$trimLines = [];
foreach ( $lines as $line )
$trimLines[] = trim( $line );
return implode( "" , $trimLines );
}

public static function parseAddsDels( string $gdir , RevcheckDataFile $file )
{
$hash = $file->hashRvtg;
$name = $file->path == "" ? $file->name : $file->path . "/" . $file->name;

$gdir = escapeshellarg( $gdir );
$hash = escapeshellarg( $hash );
$name = escapeshellarg( $name );

$output = `git -C $gdir diff --numstat $hash -- $name`;
if ( $output )
{
preg_match( '/(\d+)\s+(\d+)/' , $output , $matches );
if ( $matches )
{
$file->adds = $matches[1];
$file->dels = $matches[2];
}
}
}
}
Loading

0 comments on commit 79a06be

Please sign in to comment.