From fabb5b7a7421280b43e6f11c59d9446f6b21e3e6 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Fri, 27 Oct 2017 10:13:17 -0400 Subject: [PATCH] array_slice() passthrough for preserve_keys=true as well --- ext/standard/array.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ext/standard/array.c b/ext/standard/array.c index 89f0370461..ba09225f79 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3563,12 +3563,13 @@ PHP_FUNCTION(array_slice) return; } - if ((offset == 0) && (length >= num_in) && - HT_IS_PACKED(Z_ARRVAL_P(input)) && - HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(input))) { - /* No real slicing, and the keys will be 0..n-1, so just copy */ - ZVAL_COPY(return_value, input); - return; + if ((offset == 0) && (length >= num_in)) { + zend_array *ht = Z_ARRVAL_P(input); + if (preserve_keys || (HT_IS_PACKED(ht) && HT_IS_WITHOUT_HOLES(ht))) { + /* No real slicing, and the keys will match, so just copy */ + ZVAL_COPY(return_value, input); + return; + } } /* Initialize returned array */ -- 2.40.0