Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112316 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69776 invoked from network); 29 Nov 2020 23:01:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Nov 2020 23:01:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 86B4418053A for ; Sun, 29 Nov 2020 14:28:49 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 29 Nov 2020 14:28:49 -0800 (PST) Received: by mail-lj1-f176.google.com with SMTP id y16so14244955ljk.1 for ; Sun, 29 Nov 2020 14:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w9mcZu9Qoz27TNTM+rRiesJkbrH9LsgxF2K+VAXAWMQ=; b=fafqcB/3iQ9eQoKwb+5HaRLBj+65UoK11DCLG6X93go/o/tNNMwKl9LpONgVP1tvJJ 59IJUN9/xfTUF3ERk1jcPzYm6IEb0M7FDjkcRzrfMYEjq0x0fDR3aOsCK4aFBrk2hN71 ygDdvFMyPWk9MLCqCnDd8oRmnPMGnae/puaVovRss2mcWA1FyAYQlDuQjtm2uSclh9aI p2JecV+xw8AZWjgZ0oWkmlicK7m4J/f2XaviQcEv38jlmNy9xjU0NYM4WLKOY4SnoGxo ncKe83GsPJxfJF+jOHpxrFM1xf8zOB9IgQkeui0A/CnUyrmVzW8VFhP2A0YVQzzXrquz AvMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w9mcZu9Qoz27TNTM+rRiesJkbrH9LsgxF2K+VAXAWMQ=; b=gnUGWdrwiZ8GIN9C61UwZJx2OEeapEqj7ZM04nOR0Ggu39Y3eBbvGU2BdLgki8fECg wJ6y6QuvCvxaQE4ho3US8/2kIuERq8Daeog0Ji2wti4t3Fegr0JH4AfwwtkiwKQKyqfc ARkCoMqcjlhWDk0QGiZLEnQjZqe5BqxUqPomGFJeud1ODt80iAUV26C7+2AOHZHrr2Hy LxQEqMRnLDjyGTvkXEvvt09jaQy3OJw5bNRpJ4gcKxeXJrhzzGX9O7oMAO+nfsD9dIDH Iw+Azl0/zLf1Tzwyes9qILn6KfkflzPibz30bu1W/we4NtcHGlY+rlx3pOByIQL6J1v1 grnA== X-Gm-Message-State: AOAM532sMa77fF9d26MO18QI/5OJCPFoVLkch8iZ+Ah0K2zwhykf0QDz YJTzGxyOouP8DFCanJJRnnCkrOwQfEnqBkbSws8= X-Google-Smtp-Source: ABdhPJzz0ynsCPTBkfZZ03aNZDgI7nXCd1mAEoNYFM2nHNC9jJilXqtQoTWkQF40TnutfWwbf/kcUvNBH2JyUXwJNuU= X-Received: by 2002:a2e:8796:: with SMTP id n22mr8299738lji.345.1606688924382; Sun, 29 Nov 2020 14:28:44 -0800 (PST) MIME-Version: 1.0 References: <8bd42687f325ac9a2a97714a7ad7416da74636c28077813b0f6605c154b442cb@mahalux.com> In-Reply-To: <8bd42687f325ac9a2a97714a7ad7416da74636c28077813b0f6605c154b442cb@mahalux.com> Date: Sun, 29 Nov 2020 23:28:28 +0100 Message-ID: To: =?UTF-8?B?TWljaGFlbCBWb8WZw63FoWVrIC0gxIxWVVQgRkVM?= Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000009a3c1c05b5466a72" Subject: Re: [PHP-DEV] Detect if function is disabled from c ext From: nikita.ppv@gmail.com (Nikita Popov) --0000000000009a3c1c05b5466a72 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Nov 29, 2020 at 11:20 PM Michael Vo=C5=99=C3=AD=C5=A1ek - =C4=8CVUT= FEL < vorismi3@fel.cvut.cz> wrote: > How can a php function can be checked from extension if that function is > disabled or not? > > In php7.x, I used: > > #ifdef HAVE_CONFIG_H > #include "config.h" > #endif > > #include > #include "php.h" > > bool is_php_function_disabled(const char *func_name) { > zend_internal_function *func; > if ((func =3D zend_hash_str_find_ptr(CG(function_table), func_name, > strlen(func_name)))) { > if (func->handler =3D=3D ZEND_FN(display_disabled_function)) { > return true; > } > } > > return false; > } > > But it does not work for php8: > > In file included from /usr/local/include/php/main/php.h:35, > from .../ext/libs.c:6: > .../ext/libs.c: In function 'is_php_function_disabled': > /usr/local/include/php/Zend/zend_API.h:68:23: error: > 'zif_display_disabled_function' undeclared (first use in this function) > 68 | #define ZEND_FN(name) zif_##name > | ^~~~ > .../ext/libs.c:237:30: note: in expansion of macro 'ZEND_FN' > 237 | if (func->handler =3D=3D ZEND_FN(display_disabled_function)) { > > Thanks for help in advance. > In PHP 8, the question is ill-posed. A disabled function is indistinguishable from a function that does not exist. (You can of course check the value of the ini setting, but there should be no good reason to do so.) Nikita --0000000000009a3c1c05b5466a72--