diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1 deleted file mode 100644 index e60e22d..0000000 --- a/.appveyor/build.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -$ErrorActionPreference = "Stop" - -Set-Location 'C:\projects\uopz' - -$task = New-Item 'task.bat' -Force -Add-Content $task "call phpize 2>&1" -Add-Content $task "call configure --enable-uopz 2>&1" -Add-Content $task "nmake /nologo 2>&1" -Add-Content $task "exit %errorlevel%" -& "C:\build-cache\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VC-$env:ARCH.bat" -t $task -if (-not $?) { - throw "build failed with errorlevel $LastExitCode" -} diff --git a/.appveyor/install.ps1 b/.appveyor/install.ps1 deleted file mode 100644 index 7f4d905..0000000 --- a/.appveyor/install.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -$ErrorActionPreference = "Stop" - -if (-not (Test-Path 'C:\build-cache')) { - [void](New-Item 'C:\build-cache' -ItemType 'directory') -} - -$bname = "php-sdk-$env:BIN_SDK_VER.zip" -if (-not (Test-Path "C:\build-cache\$bname")) { - Invoke-WebRequest "https://github.com/OSTC/php-sdk-binary-tools/archive/$bname" -OutFile "C:\build-cache\$bname" -} -$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER" -$dname1 = "php-sdk-$env:BIN_SDK_VER" -if (-not (Test-Path "C:\build-cache\$dname1")) { - Expand-Archive "C:\build-cache\$bname" 'C:\build-cache' - Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1" -} - -$releases = Invoke-WebRequest https://windows.php.net/downloads/releases/releases.json | ConvertFrom-Json -$phpversion = $releases.$env:PHP_VER.version - -$ts_part = '' -if ($env:TS -eq '0') { - $ts_part += '-nts' -} -$bname = "php-devel-pack-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip" -if (-not (Test-Path "C:\build-cache\$bname")) { - try { - Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\build-cache\$bname" - } catch [System.Net.WebException] { - Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname" - } -} -$dname0 = "php-$phpversion-devel-$env:VC-$env:ARCH" -$dname1 = "php-$phpversion$ts_part-devel-$env:VC-$env:ARCH" -if (-not (Test-Path "C:\build-cache\$dname1")) { - Expand-Archive "C:\build-cache\$bname" 'C:\build-cache' - if ($dname0 -ne $dname1) { - Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1" - } -} -$env:PATH = "C:\build-cache\$dname1;$env:PATH" - -$bname = "php-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip" -if (-not (Test-Path "C:\build-cache\$bname")) { - try { - Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\build-cache\$bname" - } catch [System.Net.WebException] { - Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname" - } -} -$dname = "php-$phpversion$ts_part-$env:VC-$env:ARCH" -if (-not (Test-Path "C:\build-cache\$dname")) { - Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname" -} -$env:PATH = "c:\build-cache\$dname;$env:PATH" diff --git a/.appveyor/test.ps1 b/.appveyor/test.ps1 deleted file mode 100644 index c72fce8..0000000 --- a/.appveyor/test.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -$ErrorActionPreference = "Stop" - -$dir = 'C:\projects\uopz\' -if ($env:ARCH -eq 'x64') { - $dir += 'x64\' -} -$dir += 'Release' -if ($env:TS -eq '1') { - $dir += '_TS' -} - -$uopz_dll_opt = "-d extension=$dir\php_uopz.dll" - -Set-Location "C:\projects\uopz" - -$php = Get-Command 'php' | Select-Object -ExpandProperty 'Definition' -$dname = (Get-Item $php).Directory.FullName - -$opts = '-n' -if ($env:OPCACHE -ne '0') { - $opts += " -d zend_extension=$dname\ext\php_opcache.dll -d opcache.enabled=1 -d opcache.enable_cli=1 -d opcache.optimization_level=0" -} -$opts += " $uopz_dll_opt" -$opts += ' -duopz.exit=1' -$env:TEST_PHP_ARGS = $opts - -$env:TEST_PHP_EXECUTABLE = $php -& $php run-tests.php -q --show-diff tests -if (-not $?) { - throw "tests failed with errorlevel $LastExitCode" -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab402c7..7f43636 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,25 +4,53 @@ jobs: ubuntu: strategy: matrix: - version: ["8.0", "8.1"] + version: ["PHP-8.0", "master"] + opcache: ["opcache.enable_cli=0", "opcache.enable_cli=1"] runs-on: ubuntu-latest steps: - - name: Checkout uopz + - name: Setup Ubuntu + run: sudo apt-get install lcov re2c bison + - name: Install PHP + run: | + sudo mkdir /opt/src + sudo chmod 777 /opt/src + cd /opt/src + git clone --depth=1 --branch ${{matrix.version}} https://github.com/php/php-src + cd php-src + ./buildconf --force + ./configure --disable-all \ + --enable-gcov \ + --enable-opcache \ + --disable-opcache-jit \ + --prefix=/opt \ + --with-config-file-path=/opt/etc + make -j$(nproc) + sudo make install + - name: Checkout uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - name: Generate Build Files + run: /opt/bin/phpize + - name: Configure Build + run: ./configure --enable-uopz --with-php-config=/opt/bin/php-config + - name: Build + run: EXTRA_CFLAGS="-fprofile-arcs -ftest-coverage" make + - name: Install + run: sudo make install + - name: Configure Installation + run: | + sudo mkdir /opt/etc + sudo chmod 777 /opt/etc + echo "zend_extension=opcache.so" > /opt/etc/php.ini + echo ${{matrix.opcache}} >> /opt/etc/php.ini + - name: Run Tests + run: /opt/bin/php run-tests.php -q -g FAIL,XFAIL,XLEAK,SKIP,BORK,WARN -P --show-diff + - name: Generate Test Coverage + run: lcov -c --directory . --output-file coverage.info + - name: Coveralls + uses: coverallsapp/github-action@master with: - php-version: ${{matrix.version}} - extensions: :xdebug - ini-values: opcache.enable_cli=1 - - name: phize - run: phpize - - name: configure - run: ./configure --enable-uopz - - name: make - run: make - - name: test - run: make test TESTS=tests + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.info windows: defaults: run: @@ -48,11 +76,11 @@ jobs: with: arch: ${{matrix.arch}} toolset: ${{steps.setup-php.outputs.toolset}} - - name: phpize + - name: Generate Build Files run: phpize - - name: configure + - name: Configure Build run: configure --enable-uopz --with-prefix=${{steps.setup-php.outputs.prefix}} - - name: make + - name: Build run: nmake - - name: test + - name: Run Tests run: nmake test TESTS=tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e652bde..0000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -language: php -compiler: - - gcc -addons: - apt: - packages: - - valgrind -php: - - 8.0 - - nightly - -env: - global: - - REPORT_EXIT_STATUS=1 - - CONF="disable-uopz-coverage" - - RULE="all" - - DEF="-q --show-diff" - - MEMCHECK="-m --show-mem" - matrix: - - OPCACHE=0 TEST_PHP_ARGS="$DEF" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - OPCACHE=1 TEST_PHP_ARGS="$DEF" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - OPCACHE=0 TEST_PHP_ARGS="$DEF $MEMCHECK" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - OPCACHE=1 TEST_PHP_ARGS="$DEF $MEMCHECK" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - -matrix: - allow_failures: - - php: nightly - env: OPCACHE=0 TEST_PHP_ARGS="$DEF" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - php: nightly - env: OPCACHE=1 TEST_PHP_ARGS="$DEF" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - php: nightly - env: OPCACHE=0 TEST_PHP_ARGS="$DEF $MEMCHECK" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - - php: nightly - env: OPCACHE=1 TEST_PHP_ARGS="$DEF $MEMCHECK" CONF="enable-uopz-coverage" RULE="uopz-test-coverage-travis" - -before_install: - - test $CONF != "enable-uopz-coverage" || pip install --user cpp-coveralls - -before_script: - - echo "{" >> $HOME/default.supp - - echo "String_Equality_Intentionally_Reads_Uninit_Memory" >> $HOME/default.supp - - echo "Memcheck:Cond" >> $HOME/default.supp - - echo "fun:zend_string_equal_val" >> $HOME/default.supp - - echo "}" >> $HOME/default.supp - - echo "#!/bin/bash" >> $HOME/bin/valgrind - - echo "/usr/bin/valgrind --suppressions=$HOME/default.supp \$@" >> $HOME/bin/valgrind - - chmod +x $HOME/bin/valgrind - - export PATH=$HOME/bin:$PATH - - echo "variables_order=EGPCS" >> $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/php.ini - - echo > $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/xdebug.ini - - echo "extension=uopz.so" > $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/uopz.ini - - echo "opcache.enable_cli=$OPCACHE" > $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/opcache.ini - - echo "opcache.optimization_level=0" >> $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/opcache.ini - -script: - - cd $TRAVIS_BUILD_DIR - - phpize - - wget -q -O run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php - - ./configure --$CONF - - make $RULE - - make install - - php run-tests.php -P - -after_success: - - test $CONF != "enable-uopz-coverage" || coveralls -b $TRAVIS_BUILD_DIR -E Zend --gcov-options '\-lp' diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index add8f10..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,51 +0,0 @@ -# general configuration -version: '{branch}.{build}' - -# environment configuration -image: Visual Studio 2017 -clone_folder: c:\projects\uopz -environment: - BIN_SDK_VER: 2.2.0 - matrix: - - PHP_VER: 7.2 - TS: 0 - VC: vc15 - ARCH: x64 - OPCACHE: 0 - - PHP_VER: 7.2 - TS: 1 - VC: vc15 - ARCH: x64 - OPCACHE: 1 - - PHP_VER: 7.3 - TS: 0 - VC: vc15 - ARCH: x64 - OPCACHE: 0 - - PHP_VER: 7.3 - TS: 1 - VC: vc15 - ARCH: x64 - OPCACHE: 1 - - PHP_VER: 7.4 - TS: 0 - VC: vc15 - ARCH: x64 - OPCACHE: 0 - - PHP_VER: 7.4 - TS: 1 - VC: vc15 - ARCH: x64 - OPCACHE: 1 -cache: - - c:\build-cache -> appveyor.yml, .appveyor\install.ps1 -install: - - ps: .appveyor\install.ps1 - -# build configuration -build_script: - - ps: .appveyor\build.ps1 - -# tests configuration -test_script: - - ps: .appveyor\test.ps1 diff --git a/src/function.c b/src/function.c index 7894417..aa8746d 100644 --- a/src/function.c +++ b/src/function.c @@ -258,7 +258,7 @@ zend_bool uopz_set_static(zend_class_entry *clazz, zend_string *function, zval * zend_function *entry; zend_string *k = NULL; zval *v = NULL; - + if (clazz) { entry = uopz_find_function(&clazz->function_table, function); if (!entry) { @@ -290,7 +290,7 @@ zend_bool uopz_set_static(zend_class_entry *clazz, zend_string *function, zval * return 0; } - + if (!entry->op_array.static_variables) { if (clazz) { uopz_exception( @@ -304,15 +304,13 @@ zend_bool uopz_set_static(zend_class_entry *clazz, zend_string *function, zval * return 0; } - + HashTable *variables = ZEND_MAP_PTR_GET(entry->op_array.static_variables_ptr); if (!variables) { - ZEND_MAP_PTR_INIT( - entry->op_array.static_variables_ptr, - &entry->op_array.static_variables); - - variables = ZEND_MAP_PTR_GET(entry->op_array.static_variables_ptr); + variables = zend_array_dup(entry->op_array.static_variables); + + ZEND_MAP_PTR_SET(entry->op_array.static_variables_ptr, variables); } ZEND_HASH_FOREACH_STR_KEY_VAL(variables, k, v) { @@ -327,7 +325,7 @@ zend_bool uopz_set_static(zend_class_entry *clazz, zend_string *function, zval * continue; } - + ZVAL_COPY(v, y); } ZEND_HASH_FOREACH_END();