Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ PHP_ARG_ENABLE(brotli, whether to enable brotli support,
PHP_ARG_WITH(libbrotli, whether to use system brotli library,
[ --with-libbrotli Use libbrotli], no, no)

PHP_ARG_ENABLE(apcu, whether to enable APCu support,
[ --enable-apcu Enable APCu support], auto, no)

if test "$PHP_BROTLI" != "no"; then

BROTLI_MIN_VERSION=0.6
Expand Down Expand Up @@ -132,12 +135,14 @@ if test "$PHP_BROTLI" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/brotli/c/enc)
fi

AC_MSG_CHECKING([for APCu includes])
if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
apc_inc_path="$phpincludedir"
AC_MSG_RESULT([APCu in $apc_inc_path])
AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
else
AC_MSG_RESULT([not found])
if test "$PHP_APCU" != "no"; then
AC_MSG_CHECKING([for APCu includes])
if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
apc_inc_path="$phpincludedir"
AC_MSG_RESULT([APCu in $apc_inc_path])
AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
else
AC_MSG_RESULT([not found])
fi
fi
Comment on lines +138 to 147

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Error when APCu is explicitly enabled but the header is not found.

When a user explicitly enables APCu with --enable-apcu=yes, but the required header file is not found, the configure script should fail with an error instead of silently continuing. Currently, the script only prints "not found" and proceeds without defining HAVE_APCU_SUPPORT, which violates the user's explicit request.

The standard autoconf pattern distinguishes between:

  • --enable-apcu=auto (or default): Try to detect, continue if not found
  • --enable-apcu=yes (explicit): Require APCu, fail if not found
  • --disable-apcu or --enable-apcu=no: Skip detection
🔧 Proposed fix to error on explicit enable
   if test "$PHP_APCU" != "no"; then
     AC_MSG_CHECKING([for APCu includes])
     if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
       apc_inc_path="$phpincludedir"
       AC_MSG_RESULT([APCu in $apc_inc_path])
       AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
     else
-      AC_MSG_RESULT([not found])
+      AC_MSG_RESULT([not found])
+      if test "$PHP_APCU" = "yes"; then
+        AC_MSG_ERROR([APCu support explicitly requested but APCu headers not found])
+      fi
     fi
   fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if test "$PHP_APCU" != "no"; then
AC_MSG_CHECKING([for APCu includes])
if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
apc_inc_path="$phpincludedir"
AC_MSG_RESULT([APCu in $apc_inc_path])
AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
else
AC_MSG_RESULT([not found])
fi
fi
if test "$PHP_APCU" != "no"; then
AC_MSG_CHECKING([for APCu includes])
if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
apc_inc_path="$phpincludedir"
AC_MSG_RESULT([APCu in $apc_inc_path])
AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
else
AC_MSG_RESULT([not found])
if test "$PHP_APCU" = "yes"; then
AC_MSG_ERROR([APCu support explicitly requested but APCu headers not found])
fi
fi
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config.m4` around lines 138 - 147, When APCu was explicitly requested
(PHP_APCU == "yes") the configure script currently prints "not found" and
continues; change the logic in the APCu detection block so that after testing
for "$phpincludedir/ext/apcu/apc_serializer.h" you still set apc_inc_path and
AC_DEFINE(HAVE_APCU_SUPPORT,1,...) when found, but if the header is missing and
PHP_APCU equals "yes" call AC_MSG_ERROR with a clear failure message (e.g.,
"APCu requested but header apc_serializer.h not found in
$phpincludedir/ext/apcu") so configure aborts; if PHP_APCU is "auto" or unset
keep the existing AC_MSG_RESULT([not found]) behavior.

fi
Loading