Child pages
  • [php-compatibility] PHP 7 compatibility
Skip to end of metadata
Go to start of metadata

There will be changes in PHP 7, that will break backwards compatibility and this is an umbrella discussion so that we can pinpoint and fix all of them.

  1. usages of $this->$property['prop'] (e.g. in kDBList)
  2. usage of references inside foreach
  3. classes having method named the same as class name (the PHP4 constructor) are now deprecated
  4. usage of $HTTP_RAW_POST_DATA

Solution

The following BASH script can be used to detect some of potentially problematic places:

#!/usr/bin/env bash

# Credits for regular expressions goes to Adam Harvey (@LGnome).
case "$1" in
   indirect_references)
      REGEXP='((((::)|(->))\$[a-zA-Z_][a-zA-Z0-9_]*)+\[[^\s]+\]\(\))|(->\$[a-zA-Z_][a-zA-Z0-9_]*\[)|(\$\$[a-zA-Z_][a-zA-Z0-9_]*\[)'
      ;;
   engine_exceptions)
      REGEXP='catch\s*\(\\?Exception\s'
      ;;
   foreach)
      REGEXP='foreach.*\sas\s+&'
      ;;
   *)
      echo $"Usage: $0 {indirect_references|engine_exceptions|foreach} {folder}"
      exit 1

esac

if [ $# -eq 1 ]; then
   FOLDER="."
else
   FOLDER=$2
fi

find $FOLDER -type f -name "*.php" -not -path "*/vendor/*" -print0 | pv | xargs --null grep --color=always --line-number -E $REGEXP 

Related Tasks

INP-1436 - Getting issue details... STATUS

INP-1641 - Getting issue details... STATUS