diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index e7756ad..1188a16 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -4,104 +4,60 @@ on: [push] jobs: ci: + permissions: + contents: read + runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: - - '8.5-alpine' - - '8.5-zts-alpine' - - '8.4-alpine' - - '8.4-zts-alpine' - - '8.3-alpine' - - '8.3-zts-alpine' - - '8.2-alpine' - - '8.2-zts-alpine' - - '8.1-alpine' - - '8.1-zts-alpine' + - '8.5' + - '8.4' + - '8.3' + - '8.2' + - '8.1' + - '7.4' + - '7.3' + - '7.2' + - '7.1' + - '7.0' + ts: + - nts + - zts library: - '' - 'system' apcu: - '' - 'apcu' - image: [php] - platform: [linux/amd64] - include: - - php: '8.3-alpine' - apcu: 'apcu' - image: php - platform: linux/386 - - php: '8.2-alpine' - apcu: 'apcu' - image: php - platform: linux/386 - - php: '8.1-alpine' - apcu: 'apcu' - image: php - platform: linux/386 - - php: '8.0-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - php: '7.4-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - php: '7.3-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - php: '7.2-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - php: '7.1-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - php: '7.0-alpine' - image: ghcr.io/kjdev/php - platform: linux/amd64 - - container: - image: ${{ matrix.image }}:${{ matrix.php }} - options: --platform ${{ matrix.platform }} steps: - - name: Prepare required command (alpine) - run: | - apk upgrade --no-cache - apk add --no-cache autoconf gcc git libtool make musl-dev - if: ${{ contains(matrix.php, 'alpine') }} - - name: Prepare required command (buster) - run: | - apt-get update - apt-get install -y git - if: ${{ contains(matrix.php, 'buster') }} - - - name: adding github workspace as safe directory - run: git config --global --add safe.directory $GITHUB_WORKSPACE - name: Checkout repository - uses: actions/checkout@v4 - if: ${{ contains(matrix.platform, 'linux/amd64') }} - - name: Clone repository - run: | - git clone -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE - if: ${{ contains(matrix.platform, 'linux/386') }} - - name: Checkout submodules - run: | - git submodule update --init --recursive - if: ${{ ! matrix.library }} - - name: Install dependency library (alpine) - run: | - apk add --no-cache brotli-dev - if: ${{ matrix.library && contains(matrix.php, 'alpine') }} - - name: Install dependency library (buster) - run: | - apt-get install -y libbrotli-dev - if: ${{ matrix.library && contains(matrix.php, 'buster') }} + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + set-safe-directory: true + submodules: ${{ ! matrix.library }} + token: ${{ github.token }} - - name: Install PHP APCu extension + - name: Setup PHP (${{ matrix.php }} ${{ matrix.ts }}) + uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1 + with: + php-version: ${{ matrix.php }} + extensions: xml, mbstring${{ matrix.apcu != '' && ', apcu' || '' }} + coverage: none + ini-values: zend.assertions=1 + env: + phpts: ${{ matrix.ts }} + + - name: Install dependency library run: | - printf "\n" | pecl install apcu - echo 'extension=apcu.so' > $(php --ini | grep 'Scan for' | sed -e 's/"//g' -e 's|.* \(/.*\)$|\1|')/apcu.ini - if: ${{ matrix.apcu }} + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + libbrotli-dev + if: ${{ matrix.library }} - name: Build run: | @@ -119,7 +75,7 @@ jobs: - name: Test Preparation APCu run: | cp $(php-config --extension-dir)/apcu.so modules/ - sed -i 's/\$(PHP_TEST_SHARED_EXTENSIONS)/-d extension=apcu \$(PHP_TEST_SHARED_EXTENSIONS)/' Makefile + sed -i 's/\$(PHP_TEST_SHARED_EXTENSIONS)/-d extension=apcu.so \$(PHP_TEST_SHARED_EXTENSIONS)/' Makefile if: ${{ matrix.apcu }} - name: Test run: | diff --git a/.github/workflows/submodule.ps1 b/.github/workflows/submodule.ps1 deleted file mode 100644 index 6c1f67b..0000000 --- a/.github/workflows/submodule.ps1 +++ /dev/null @@ -1,2 +0,0 @@ - -Invoke-Expression "git submodule update --init --recursive" diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 18d7b21..4cc11dc 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -34,7 +34,7 @@ jobs: - true exclude: - php: '8.5' - vs: vs16 + vs: vs16 - php: '8.4' vs: vs16 - php: '8.3' @@ -56,14 +56,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false + set-safe-directory: true + submodules: ${{ ! matrix.library }} + token: ${{ github.token }} - - name: Checkout submodule - run: .\.github\workflows\submodule.ps1 - shell: pwsh - if: ${{ ! matrix.library }} - name: Install dependency library run: .\.github\workflows\vcpkg.ps1 shell: pwsh @@ -71,7 +70,7 @@ jobs: VCPKG_LIBRARY: brotli if: ${{ matrix.library }} - - uses: actions/cache@v4 + - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: | C:\php\php-*.zip @@ -105,7 +104,7 @@ jobs: - if: ${{ github.event_name == 'release' && matrix.library == false }} name: Store archive DLL - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: ${{ env.PHP_EXT_VERSION }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch == 'x64' && 'x86_64' || matrix.arch }} path: .\php_${{ env.PHP_EXT }}-${{ env.PHP_EXT_VERSION }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch == 'x64' && 'x86_64' || matrix.arch }}.zip @@ -122,12 +121,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false + set-safe-directory: true + token: ${{ github.token }} - name: Get artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: path: artifacts merge-multiple: true diff --git a/brotli.c b/brotli.c index b4c73aa..7f28102 100644 --- a/brotli.c +++ b/brotli.c @@ -130,7 +130,7 @@ static zend_always_inline zend_string *smart_str_extract(smart_str *str) { str->s = NULL; return res; } else { - return ZSTR_EMPTY_ALLOC(); + return zend_string_init("", 0, 0); } } #endif @@ -1843,6 +1843,9 @@ static ZEND_FUNCTION(brotli_uncompress_add) #if defined(HAVE_APCU_SUPPORT) static int APC_SERIALIZER_NAME(brotli)(APC_SERIALIZER_ARGS) { +#if defined(COMPILE_DL_BROTLI) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif int result; int lgwin = BROTLI_DEFAULT_WINDOW; long level = BROTLI_G(apcu_compression_level); @@ -1883,6 +1886,9 @@ static int APC_SERIALIZER_NAME(brotli)(APC_SERIALIZER_ARGS) static int APC_UNSERIALIZER_NAME(brotli)(APC_UNSERIALIZER_ARGS) { +#if defined(COMPILE_DL_BROTLI) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif const uint8_t *next_in = (const uint8_t*) buf; const unsigned char* tmp; int result;