Setting httpd directive via Scope fails

Running the following command:

cpcmd scope:set apache.system-directive '[BROTLI,STRICT,CACHE_MEMORY,STATUS]'

# this doesn't work any better
cpcmd scope:set apache.system-directive '["BROTLI","STRICT","CACHE_MEMORY","STATUS"]'

Results in a broken directive, as some array to string conversion occurs:

[root@web6 ~]# cpcmd scope:get apache.system-directive
- BROTLI
- STRICT
- CACHE_MEMORY
- Array

Error trace:

WARNING: Array to string conversion [/usr/local/apnscp/lib/Opcenter/Admin/Settings/Apache/SystemDirective.php:43]
        0. Opcenter\Admin\Settings\Apache\SystemDirective->set(["BROTLI", "STRICT", "CACHE_MEMORY", "STATUS"])
           [/usr/local/apnscp/lib/modules/scope.php:68]
        1. Scope_Module->set("apache.system-directive", ["BROTLI", "STRICT", "CACHE_MEMORY", "STATUS"])
           [/usr/local/apnscp/lib/Module/Skeleton/Standard.php:145]
        2. Module\Skeleton\Standard->_invoke("set", ["apache.system-directive", [["BROTLI", "STRICT", "CACHE_MEMORY", "STATUS"]]])
           [/usr/local/apnscp/lib/apnscpfunction.php:992]
        3. apnscpFunctionInterceptor->call("scope_set", ["apache.system-directive", [["BROTLI", "STRICT", "CACHE_MEMORY", "STATUS"]]])
           [/usr/local/apnscp/lib/CLI/cmd.php:62]
        4. CLI\__call("scope_set", ["apache.system-directive", [["BROTLI", "STRICT", "CACHE_MEMORY", "STATUS"]]])
           [/usr/local/apnscp/lib/CLI/cmd.php:581]
        5. CLI\main()
           [/usr/local/apnscp/bin/cmd:7]

Triage

  • What version of apnscp are you running?
    [root@web6 ~]# cpcmd misc_cp_version
    revision: b30a6a04b5eab1133a6fa2095ab7d16d0f223df7
    timestamp: 1710360209
    ver_maj: 3
    ver_min: 2
    ver_patch: 41
    ver_pre: ''
    dirty: false
    debug: false
    
  • Which version of RHEL or CentOS are you using?
    [root@web6 ~]# cat /etc/redhat-release
    Red Hat Enterprise Linux release 8.9 (Ootpa)
    
  • Can you reproduce this bug reliably?
    Yes, reproduced on 2 nodes.

Fixed in edge. Expected input is a single directive, rather than list. Expanded the supported types to accept a list or hash (directive: bool).

Only time you would need something like that would be if the value could be parsed as a float or int and you’d like for it to be a string, e.g. cpcmd -d site1 web:add-subdomain 1 would be invalid because 1 is interpreted as an integer, cpcmd -d site1 web:add-subdomain "'1'" would be correct, note the inner + outer quotes. Outer quotes is to protect shell interpolation from stripping the inner quotes.

1 Like