Skip to content

Instantly share code, notes, and snippets.

@jverdeyen
Forked from waja/php54_deprecated_functions
Created October 1, 2013 12:38
Show Gist options
  • Save jverdeyen/6777809 to your computer and use it in GitHub Desktop.
Save jverdeyen/6777809 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# PHP 5.4 Deprecated function checker
#
# Version: 0.0.3
#
# Original Author: Michiel Roos <michiel@donationbasedhosting.org>
#
# http://www.php.net/manual/de/migration54.incompatible.php
# http://www.php.net/manual/en/migration54.deprecated.php
#
# Please note that there will be some false positives. Some PHP code is mixed
# with JS code. In JS 'split' is still a valid function.
#
PWD="/tmp"
FIND_PHP54_DEPRECATED_LOGLOCATION="php54_deprecated_functions.log"
OUTPUT=${PWD}/${FIND_PHP54_DEPRECATED_LOGLOCATION}
deprecatedFunctions54=(
# php 5.4 removed
define_syslog_variables
import_request_variables
session_is_registered
session_register
session_unregister
mysqli_bind_param
mysqli_bind_result
mysqli_client_encoding
mysqli_fetch
mysqli_param_count
mysqli_get_metadata
mysqli_send_long_data
mysqli::client_encoding
mysqli_stmt::stmt
# php 5.4 changed behavior
get_magic_quotes_gpc
get_magic_quotes_runtime
set_magic_quotes_runtime
# php 5.4 deprecated
mcrypt_generic_end
mysql_list_dbs
)
deprecatedIniDirectives54=(
# php 5.4
register_globals
register_long_arrays
)
len=${#deprecatedFunctions54[*]}
i=0
echo "Checking for deprectated functions in PHP 5.4 ______________________________________" > ${OUTPUT}
echo "" >> ${OUTPUT}
while [ $i -lt $len ]; do
echo " // checking for '${deprecatedFunctions54[$i]}()'" >> ${OUTPUT}
grep -rn --color --include=*.php "^[^#]*[^a-zA-Z_]${deprecatedFunctions54[$i]}[[:space:]]*(" * >> ${OUTPUT};
echo "" >> ${OUTPUT}
let i++
done
len=${#deprecatedIniDirectives54[*]}
i=0
echo "Checking for deprectated ini directives in PHP 5.4 _________________________________" >> ${OUTPUT}
echo "" >> ${OUTPUT}
while [ $i -lt $len ]; do
echo " // checking for '${deprecatedIniDirectives54[$i]}()'" >> ${OUTPUT}
grep -rn --color --include=*.php "ini_set[[:space:]]*(['|\"]${deprecatedIniDirectives54[$i]}" * >> ${OUTPUT};
echo "" >> ${OUTPUT}
let i++
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment