diff options
| -rw-r--r-- | .gitignore | 9 | ||||
| -rw-r--r-- | 0001-Cleanups-in-config.m4.patch | 69 | ||||
| -rw-r--r-- | 0001-display-configuration-in-phpinfo.patch | 25 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | PHPINFO | 14 | ||||
| -rw-r--r-- | REFLECTION | 72 | ||||
| -rw-r--r-- | composer.json | 21 | ||||
| -rw-r--r-- | php-wikimedia-wikidiff2.spec | 145 |
8 files changed, 359 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/0001-Cleanups-in-config.m4.patch b/0001-Cleanups-in-config.m4.patch new file mode 100644 index 0000000..81d2789 --- /dev/null +++ b/0001-Cleanups-in-config.m4.patch @@ -0,0 +1,69 @@ +From 277f93cd193576e7cae9889d12d490de0db21738 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Fri, 12 Jun 2026 06:52:46 +0200 +Subject: [PATCH] Cleanups in config.m4 + +* use c++ linker +* use PKG_CHECK_MODULES +* Fix for out of sources tree builds +* move build options to PHP_NEW_EXTENSION + +Change-Id: I4f0521446dbf764c879c8c51fe5ead3c5a16fbea +--- + config.m4 | 27 ++++++++------------------- + 1 file changed, 8 insertions(+), 19 deletions(-) + +diff --git a/config.m4 b/config.m4 +index 6c7c4e1..f468f63 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -4,24 +4,10 @@ PHP_ARG_ENABLE(wikidiff2, whether to enable wikidiff2 support, + if test "$PHP_WIKIDIFF2" != "no"; then + PHP_REQUIRE_CXX + AC_LANG_CPLUSPLUS +- PHP_ADD_LIBRARY(stdc++,,WIKIDIFF2_SHARED_LIBADD) + +- if test -z "$PKG_CONFIG" +- then +- AC_PATH_PROG(PKG_CONFIG, pkg-config, no) +- fi +- if test "$PKG_CONFIG" = "no" +- then +- AC_MSG_ERROR([required utility 'pkg-config' not found]) +- fi +- +- if ! $PKG_CONFIG --atleast-version=0.1.25 --exists libthai +- then +- AC_MSG_ERROR(['libthai' is not in pkg-config or version < 0.1.25]) +- fi +- +- PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags-only-I libthai`) +- PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libthai`, WIKIDIFF2_SHARED_LIBADD) ++ PKG_CHECK_MODULES([LIBTHAI], [libthai >= 0.1.25]) ++ PHP_EVAL_INCLINE([$LIBTHAI_CFLAGS]) ++ PHP_EVAL_LIBLINE([$LIBTHAI_LIBS], [WIKIDIFF2_SHARED_LIBADD]) + + export OLD_CPPFLAGS="$CPPFLAGS" + export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_WIKIDIFF2" +@@ -30,7 +16,6 @@ if test "$PHP_WIKIDIFF2" != "no"; then + + PHP_SUBST(WIKIDIFF2_SHARED_LIBADD) + AC_DEFINE(HAVE_WIKIDIFF2, 1, [ ]) +- export CXXFLAGS="-Wno-write-strings -std=c++17 $CXXFLAGS" + PHP_NEW_EXTENSION(wikidiff2, \ + src/php_wikidiff2.cpp \ + src/lib/Wikidiff2.cpp \ +@@ -42,5 +27,9 @@ if test "$PHP_WIKIDIFF2" != "no"; then + src/lib/LineDiffProcessor.cpp \ + src/lib/WordDiffCache.cpp \ + src/lib/WordDiffSegmenter.cpp \ +- src/lib/WordDiffStats.cpp, $ext_shared) ++ src/lib/WordDiffStats.cpp, $ext_shared,, [-Wno-write-strings -std=c++17], [cxx]) ++ ++ PHP_ADD_BUILD_DIR($ext_builddir/src) ++ PHP_ADD_BUILD_DIR($ext_builddir/src/lib) ++ PHP_ADD_INCLUDE($ext_srcdir/src) + fi +-- +2.54.0 + diff --git a/0001-display-configuration-in-phpinfo.patch b/0001-display-configuration-in-phpinfo.patch new file mode 100644 index 0000000..bd78de2 --- /dev/null +++ b/0001-display-configuration-in-phpinfo.patch @@ -0,0 +1,25 @@ +From fa521ad798b1e56ee5b665d6984fda0115509706 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Fri, 12 Jun 2026 08:59:09 +0200 +Subject: [PATCH] display configuration in phpinfo + +--- + src/php_wikidiff2.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/php_wikidiff2.cpp b/src/php_wikidiff2.cpp +index 2ea23ab..d45b68e 100644 +--- a/src/php_wikidiff2.cpp ++++ b/src/php_wikidiff2.cpp +@@ -100,6 +100,8 @@ PHP_MINFO_FUNCTION(wikidiff2) + php_info_print_table_header(2, "wikidiff2 support", "enabled"); + php_info_print_table_row(2, "wikidiff2 version", WIKIDIFF2_VERSION_STRING); + php_info_print_table_end(); ++ ++ DISPLAY_INI_ENTRIES(); + } + + /** +-- +2.54.0 + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + @@ -0,0 +1,14 @@ + +wikidiff2 + +wikidiff2 support => enabled +wikidiff2 version => 1.14.2 + +Directive => Local Value => Master Value +wikidiff2.change_threshold => 0.2 => 0.2 +wikidiff2.moved_line_threshold => 0.4 => 0.4 +wikidiff2.moved_paragraph_detection_cutoff => 100 => 100 +wikidiff2.max_word_level_diff_complexity => 40000000 => 40000000 +wikidiff2.max_split_size => 1 => 1 +wikidiff2.initial_split_threshold => 0.1 => 0.1 +wikidiff2.final_split_threshold => 0.6 => 0.6 diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..71c5863 --- /dev/null +++ b/REFLECTION @@ -0,0 +1,72 @@ +Extension [ <persistent> extension #136 wikidiff2 version 1.14.2 ] { + + - INI { + Entry [ wikidiff2.change_threshold <ALL> ] + Current = '0.2' + } + Entry [ wikidiff2.moved_line_threshold <ALL> ] + Current = '0.4' + } + Entry [ wikidiff2.moved_paragraph_detection_cutoff <ALL> ] + Current = '100' + } + Entry [ wikidiff2.max_word_level_diff_complexity <ALL> ] + Current = '40000000' + } + Entry [ wikidiff2.max_split_size <ALL> ] + Current = '1' + } + Entry [ wikidiff2.initial_split_threshold <ALL> ] + Current = '0.1' + } + Entry [ wikidiff2.final_split_threshold <ALL> ] + Current = '0.6' + } + } + + - Functions { + Function [ <internal:wikidiff2> function wikidiff2_do_diff ] { + + - Parameters [3] { + Parameter #0 [ <required> string $text1 ] + Parameter #1 [ <required> string $text2 ] + Parameter #2 [ <required> int $numContextLines ] + } + - Return [ string ] + } + Function [ <internal:wikidiff2> function wikidiff2_inline_diff ] { + + - Parameters [3] { + Parameter #0 [ <required> string $text1 ] + Parameter #1 [ <required> string $text2 ] + Parameter #2 [ <required> int $numContextLines ] + } + - Return [ string ] + } + Function [ <internal:wikidiff2> function wikidiff2_inline_json_diff ] { + + - Parameters [3] { + Parameter #0 [ <required> string $text1 ] + Parameter #1 [ <required> string $text2 ] + Parameter #2 [ <required> int $numContextLines ] + } + - Return [ string ] + } + Function [ <internal:wikidiff2> function wikidiff2_version ] { + + - Parameters [0] { + } + - Return [ string ] + } + Function [ <internal:wikidiff2> function wikidiff2_multi_format_diff ] { + + - Parameters [3] { + Parameter #0 [ <required> string $text1 ] + Parameter #1 [ <required> string $text2 ] + Parameter #2 [ <optional> array $options = [] ] + } + - Return [ array ] + } + } +} + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a308854 --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "wikimedia/wikidiff2", + "description": "Wikidiff2 is a PHP extension which formats changes between two input texts, producing HTML or JSON.", + "type": "php-ext", + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "Tim Starling", + "email": "tstarling@wikimedia.org" + }, + { + "name": "Wikimedia Community" + } + ], + "php-ext": { + "extension-name": "wikidiff2" + }, + "require": { + "php": ">=8.2" + } +} diff --git a/php-wikimedia-wikidiff2.spec b/php-wikimedia-wikidiff2.spec new file mode 100644 index 0000000..73021d5 --- /dev/null +++ b/php-wikimedia-wikidiff2.spec @@ -0,0 +1,145 @@ +# remirepo spec file for php-wikimedia-wikidiff2 +# +# SPDX-FileCopyrightText: Copyright 2026 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +# +# Please, preserve the changelog entries +# +%{?scl:%scl_package php-wikimedia-wikidiff2} + +%bcond_without tests + +%global gh_owner wikimedia +%global gh_project mediawiki-php-wikidiff2 +%global ext_name wikidiff2 +%global pie_vend %{gh_owner} +%global pie_proj %{ext_name} +%global ini_name 40-%{ext_name}.ini +%global forgeurl https://github.com/%{gh_owner}/%{gh_project} +%global tag %{version} +# for EL-8 to avoid TAG usage +%global archivename %{gh_project}-%{tag} + +Name: %{?scl_prefix}php-%{pie_vend}-%{pie_proj} +Summary: Formats changes between two input texts +License: GPL-2.0-or-later +Version: 1.14.2 +Release: 1%{?dist} +%forgemeta +URL: %{forgeurl} +Source0: %{forgesource} + +# https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1 +Patch0: 0001-Cleanups-in-config.m4.patch +# https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1 +Patch1: 0001-display-configuration-in-phpinfo.patch + +BuildRequires: make +BuildRequires: %{?dtsprefix}gcc-c++ +BuildRequires: %{?scl_prefix}php-devel >= 8.2 +BuildRequires: pkgconfig(libthai) >= 0.1.25 + +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} + +# Extension +Provides: %{?scl_prefix}php-%{ext_name} = %{version} +Provides: %{?scl_prefix}php-%{ext_name}%{?_isa} = %{version} +# PIE +Provides: %{?scl_prefix}php-pie(%{pie_vend}/%{pie_proj}) = %{version} + + +%description +Wikidiff2 is a PHP extension which formats changes between two input texts, +producing HTML or JSON. + +It performs word-level diffs, including support for Thai word segmentation. +It can detect moved and split lines. + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%prep +%forgesetup + +%patch -P0 -p1 -b .pr1 +%patch -P1 -p1 -b .pr2 + +# Sanity check, really often broken +extver=$(sed -n '/#define WIKIDIFF2_VERSION_STRING/{s/.* "//;s/".*$//;p}' src/php_wikidiff2.cpp) +if test "x${extver}" != "x%{version}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}. + exit 1 +fi + +# Drop in the bit of configuration +cat << 'EOF' | tee %{ini_name} +; Enable '%{ext_name}' extension module +extension = %{ext_name} + +; Configuration +;wikidiff2.change_threshold = 0.2 +;wikidiff2.moved_line_threshold = 0.4 +;wikidiff2.moved_paragraph_detection_cutoff = 100 +;wikidiff2.max_word_level_diff_complexity = 40000000 +;wikidiff2.max_split_size = 1 +;wikidiff2.initial_split_threshold = 0.1 +;wikidiff2.final_split_threshold = 0.6 +EOF + + +%build +%{?dtsenable} + +%{__phpize} +sed -e 's/INSTALL_ROOT/DESTDIR/' -i build/Makefile.global + +%configure \ + --with-php-config=%{__phpconfig} \ + --with-libdir=%{_lib} \ + --enable-wikidiff2 + +%make_build + + +%install +%{?dtsenable} + +# Install the NTS stuff +%make_install +install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + + +%check +: Minimal load test for NTS extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{ext_name}.so \ + --modules | grep '^%{ext_name}$' + +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{ext_name}.so \ + --ri %{ext_name} + +%if %{with tests} +: Upstream test suite for NTS extension +TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{ext_name}.so" \ +%{__php} -n run-tests.php --show-diff %{?_smp_mflags} +%endif + + +%files +%license COPYING +%doc composer.json +%doc *.md + +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{ext_name}.so + + + +%changelog +* Fri Jun 12 2026 Remi Collet <remi@remirepo.net> - 1.14.2-1 +- new package +- open https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1 Cleanups in config.m4 +- open https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/2 display configuration |
