Skip to content

Instantly share code, notes, and snippets.

@waja
Last active March 11, 2016 13:18
Show Gist options
  • Save waja/6552974 to your computer and use it in GitHub Desktop.
Save waja/6552974 to your computer and use it in GitHub Desktop.
This shell script could be used to parse DocumentRoots for functions and ini directives problematic with PHP 5.4
#!/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
array_combine
htmlspecialchars
htmlentities
ob_start
# 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
@mirabilos
Copy link

We’re at 5.5 already though, mind you ;-)

@waja
Copy link
Author

waja commented Sep 17, 2013

Indeed, PHP is at 5.5, but Debian is on stable at 5.4! ,)

@mirabilos
Copy link

But nobody runs stale ;-)

@aanton
Copy link

aanton commented Feb 11, 2014

Any reason for not including function htmlentities?

@waja
Copy link
Author

waja commented Feb 21, 2014

No, just missing! ;)

@aanton
Copy link

aanton commented Feb 24, 2014

Great! :)

I also suggest adding these two functions:

  • html_entity_decode
  • get_html_translation_table

@waja
Copy link
Author

waja commented Mar 18, 2015

@aanton Oh I missed your comment. Anyway, those seems not to be deprecated at least when looking into http://php.net/manual/function.html-entity-decode.php or http://php.net/manual/function.get-html-translation-table.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment