Le 26/09/2023 à 19:32, Carlos O'Donell a écrit :

In version 8.3 (F40) we'll includes the UTC definition
in our patch to use system tzdata, UTC being use
as the fallback value.

I'm curious; what does this patch look like?

(trivial) patch to our system tzdata patch attached

In short, if file is missing use bundled content

Full patch for PHP 8.3:
https://git.remirepo.net/cgit/rpms/scl-php83/php.git/plain/php-8.3.0-systzdata-v24.patch

Remi


P.S. IMHO, allowing removal of tzdata for PHP doesn't make any sense
as most app will fail badly (runtime exception) because of missing
TZ when upstream use a bundle copy of the full database, so this can
never happen, so this will create another RPM specific problem
(when upstream is opposed to our change, for years)
From db0a54781ce95dbbe7adbf26346322075794a931 Mon Sep 17 00:00:00 2001
From: Remi Collet <r...@remirepo.net>
Date: Fri, 22 Sep 2023 15:56:38 +0200
Subject: [PATCH] add internal UTC if tzdata is missing

---
 ext/date/lib/parse_tz.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index 648d16c12c..ec196a98b6 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -35,6 +35,17 @@
 
 #include "php_scandir.h"
 
+static const unsigned char internal_utc[] = {
+        0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+        0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x0a, 0x55, 0x54, 0x43,
+        0x30, 0x0a
+};
+
 #else
 #define TIMELIB_SUPPORTS_V2DATA
 #define TIMELIB_SUPPORT_SLIM_FILE
@@ -934,6 +945,9 @@ static void create_zone_index(timelib_tzdb *db)
 
         qsort(db_index, index_next, sizeof *db_index, sysdbcmp);
 
+	if (!index_next) {
+		db_index[index_next++].id = strdup("UTC");
+	}
 	db->index = db_index;
 	db->index_size = index_next;
 
@@ -1040,7 +1054,12 @@ static char *map_tzfile(const char *timezone, size_t *length)
 
 	fd = open(fname, O_RDONLY);
 	if (fd == -1) {
-		return NULL;
+		if (strcmp(timezone, "UTC")) {
+			return NULL;
+		} else {
+			*length = sizeof(internal_utc);
+			return internal_utc;
+		}
 	} else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st, fd)) {
 		close(fd);
 		return NULL;
@@ -1111,7 +1130,7 @@ const timelib_tzdb *timelib_builtin_db(void)
 	if (timezonedb_system == NULL) {
 		timelib_tzdb *tmp = malloc(sizeof *tmp);
 
-		tmp->version = "0.system";
+		tmp->version = "0";
 		tmp->data = NULL;
 		create_zone_index(tmp);
 		retrieve_zone_version(tmp);
@@ -1144,7 +1163,9 @@ int timelib_timezone_id_is_valid(const char *timezone, const timelib_tzdb *tzdb)
 		if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
 			return 0;
 		}
-
+		if (!strcmp(timezone, "UTC")) {
+			return 1;
+		}
 		if (system_location_table) {
 			if (find_zone_info(system_location_table, timezone) != NULL) {
 				/* found in cache */
@@ -1274,7 +1295,9 @@ timelib_tzinfo *timelib_parse_tzfile(const char *timezone, const timelib_tzdb *t
 			}
 
 			/* Now done with the mmap segment - discard it. */
-			munmap(memmap, maplen);
+			if (memmap != internal_utc) {
+				munmap(memmap, maplen);
+			}
 		} else {
 #endif
 		if (type == TIMELIB_TZINFO_PHP) {
-- 
2.41.0

_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to