Merge pull request #600 from jgen/develop

Bump PHP version up to 5.6 & Linting/fixes
This commit is contained in:
Shish 2017-03-10 11:11:38 +00:00 committed by GitHub
commit 55ee93fd27
16 changed files with 1455 additions and 62 deletions

View file

@ -1,9 +1,8 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
sudo: false

View file

@ -29,7 +29,7 @@ check out one of the versioned branches.
# Requirements
- MySQL/MariaDB 5.1+ (with experimental support for PostgreSQL 9+ and SQLite 3)
- [Stable PHP](https://en.wikipedia.org/wiki/PHP#Release_history) (5.5 as of writing)
- [Stable PHP](https://en.wikipedia.org/wiki/PHP#Release_history) (5.6+ as of writing)
- GD or ImageMagick
# Installation

View file

@ -19,7 +19,7 @@
],
"require" : {
"php" : ">=5.4.8",
"php" : ">=5.6",
"flexihash/flexihash" : "^2.0.0",
"ifixit/php-akismet" : "1.*",
@ -29,11 +29,15 @@
"bower-asset/jquery" : "1.12.3",
"bower-asset/jquery-timeago" : "1.5.2",
"bower-asset/tablesorter" : "2.0.5",
"bower-asset/tablesorter" : "2.*",
"bower-asset/mediaelement" : "2.21.1",
"bower-asset/js-cookie" : "2.1.1"
},
"require-dev" : {
"phpunit/phpunit" : "5.*"
},
"vendor-copy": {
"vendor/bower-asset/jquery/dist/jquery.min.js" : "lib/vendor/js/jquery-1.12.3.min.js",
"vendor/bower-asset/jquery/dist/jquery.min.map" : "lib/vendor/js/jquery-1.12.3.min.map",

1343
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -263,11 +263,34 @@ class SQLite extends DBEngine {
// }}}
// {{{ cache engines
interface CacheEngine {
/**
* @param string $key
* @return mixed
*/
public function get($key);
/**
* @param string $key
* @param mixed $val
* @param integer $time
* @return void
*/
public function set($key, $val, $time=0);
/**
* @return void
*/
public function delete($key);
/**
* @return integer
*/
public function get_hits();
/**
* @return integer
*/
public function get_misses();
}
class NoCache implements CacheEngine {
@ -324,7 +347,7 @@ class MemcacheCache implements CacheEngine {
/**
* @param string $key
* @param mixed $val
* @param int $time
* @param integer $time
*/
public function set($key, $val, $time=0) {
assert('!is_null($key)');
@ -401,6 +424,10 @@ class Database {
* @var null|PDO
*/
private $db = null;
/**
* @var float
*/
public $dbtime = 0.0;
/**
@ -509,7 +536,7 @@ class Database {
}
/**
* @return bool
* @return boolean|null
* @throws SCoreException
*/
public function commit() {
@ -525,7 +552,7 @@ class Database {
}
/**
* @return bool
* @return boolean|null
* @throws SCoreException
*/
public function rollback() {
@ -566,6 +593,10 @@ class Database {
return $this->engine->name;
}
/**
* @param null|PDO $db
* @param string $sql
*/
private function count_execs($db, $sql, $inputarray) {
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
$fp = @fopen("data/sql.log", "a");
@ -786,35 +817,35 @@ class MockDatabase extends Database {
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
* @return PDOStatement
*/
public function get_all($query, $args=array()) {return $this->execute($query, $args);}
/**
* @param string $query
* @param array $args
* @return mixed|null|PDOStatement
* @return PDOStatement
*/
public function get_row($query, $args=array()) {return $this->execute($query, $args);}
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
* @return PDOStatement
*/
public function get_col($query, $args=array()) {return $this->execute($query, $args);}
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
* @return PDOStatement
*/
public function get_pairs($query, $args=array()) {return $this->execute($query, $args);}
/**
* @param string $query
* @param array $args
* @return mixed|PDOStatement
* @return PDOStatement
*/
public function get_one($query, $args=array()) {return $this->execute($query, $args);}

View file

@ -92,6 +92,9 @@ abstract class Extension {
$this->theme = $this->get_theme_object(get_called_class());
}
/**
* @return boolean
*/
public function is_live() {
global $database;
return (

View file

@ -175,6 +175,10 @@ class Image {
return $images;
}
/**
* @param string[] $tags
* @return boolean
*/
public function validate_accel($tags) {
$yays = 0;
$nays = 0;

View file

@ -8,7 +8,7 @@ require_once "lib/context.php";
/**
* Make some data safe for printing into HTML
*
* @param $input
* @param string $input
* @return string
*/
function html_escape($input) {
@ -18,7 +18,7 @@ function html_escape($input) {
/**
* Unescape data that was made safe for printing into HTML
*
* @param $input
* @param string $input
* @return string
*/
function html_unescape($input) {
@ -28,7 +28,7 @@ function html_unescape($input) {
/**
* Make sure some data is safe to be used in integer context
*
* @param $input
* @param string $input
* @return int
*/
function int_escape($input) {
@ -42,7 +42,7 @@ function int_escape($input) {
/**
* Make sure some data is safe to be used in URL context
*
* @param $input
* @param string $input
* @return string
*/
function url_escape($input) {
@ -77,7 +77,7 @@ function url_escape($input) {
/**
* Make sure some data is safe to be used in SQL context
*
* @param $input
* @param string $input
* @return string
*/
function sql_escape($input) {
@ -90,7 +90,7 @@ function sql_escape($input) {
* Turn all manner of HTML / INI / JS / DB booleans into a PHP one
*
* @param mixed $input
* @return bool
* @return boolean
*/
function bool_escape($input) {
/*
@ -125,7 +125,7 @@ function bool_escape($input) {
* Some functions require a callback function for escaping,
* but we might not want to alter the data
*
* @param $input
* @param string $input
* @return string
*/
function no_escape($input) {
@ -202,7 +202,7 @@ function truncate($string, $limit, $break=" ", $pad="...") {
/**
* Turn a human readable filesize into an integer, eg 1KB -> 1024
*
* @param $limit
* @param string|integer $limit
* @return int
*/
function parse_shorthand_int($limit) {
@ -232,7 +232,7 @@ function parse_shorthand_int($limit) {
/**
* Turn an integer into a human readable filesize, eg 1024 -> 1KB
*
* @param $int
* @param integer $int
* @return string
*/
function to_shorthand_int($int) {
@ -254,7 +254,7 @@ function to_shorthand_int($int) {
/**
* Turn a date into a time, a date, an "X minutes ago...", etc
*
* @param $date
* @param string $date
* @param bool $html
* @return string
*/
@ -267,7 +267,7 @@ function autodate($date, $html=true) {
/**
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
*
* @param $dateTime
* @param string $dateTime
* @return bool
*/
function isValidDateTime($dateTime) {
@ -283,7 +283,7 @@ function isValidDateTime($dateTime) {
/**
* Check if a given string is a valid date. ( Format: yyyy-mm-dd )
*
* @param $date
* @param string $date
* @return bool
*/
function isValidDate($date) {
@ -297,6 +297,9 @@ function isValidDate($date) {
return false;
}
/**
* @param string[] $inputs
*/
function validate_input($inputs) {
$outputs = array();
@ -391,8 +394,8 @@ function validate_input($inputs) {
*
* FIXME: also check that IP ban ext is installed
*
* @param $ip
* @param $ban_reason
* @param string $ip
* @param string $ban_reason
* @return string
*/
function show_ip($ip, $ban_reason) {
@ -616,6 +619,7 @@ function zglob($pattern) {
/**
* Gets contact link as mailto: or http:
* @return string
*/
function contact_link() {
global $config;
@ -1734,6 +1738,9 @@ function _get_user() {
return $user;
}
/**
* @return string
*/
function _get_query() {
return @$_POST["q"]?:@$_GET["q"];
}

View file

@ -86,6 +86,12 @@ xanax
$event->panel->add_block($sb);
}
/**
* Throws if the comment contains banned words.
* @param string $comment
* @param CommentPostingException|SCoreException $ex
* @throws CommentPostingException|SCoreException if the comment contains banned words.
*/
private function test_text($comment, $ex) {
$comment = strtolower($comment);
@ -105,6 +111,9 @@ xanax
}
}
/**
* @return string[]
*/
private function get_words() {
global $config;
$words = array();

View file

@ -59,6 +59,11 @@ class _SafeOuroborosImage
* @var integer
*/
public $width = null;
/**
* File extension
* @var string
*/
public $file_ext = '';
/**
* File Size in bytes
* @var integer
@ -189,7 +194,7 @@ class _SafeOuroborosImage
* Constructor
* @param Image $img
*/
function __construct(Image $img)
public function __construct(Image $img)
{
global $config;
// author
@ -343,7 +348,7 @@ class _SafeOuroborosTag
public $name = '';
public $type = 0;
function __construct(array $tag)
public function __construct(array $tag)
{
$this->count = $tag['count'];
$this->id = $tag['id'];

View file

@ -157,6 +157,11 @@ class SetupBlock extends Block {
$this->body .= "<input type='hidden' name='_type_$name' value='int'>\n";
}
/**
* @param string $name
* @param string[] $options
* @param null|string $label
*/
public function add_choice_option($name, $options, $label=null) {
global $config;
$current = $config->get_string($name);
@ -176,6 +181,11 @@ class SetupBlock extends Block {
$this->body .= $html;
}
/**
* @param string $name
* @param string[] $options
* @param null|string $label
*/
public function add_multichoice_option($name, $options, $label=null) {
global $config;
$current = $config->get_array($name);

View file

@ -83,18 +83,6 @@ class TagEditCloud extends Extension {
}
switch($sort_method) {
case 'a':
case 'p':
default:
$order_by = $sort_method == 'a' ? "tag" : "count DESC";
$tag_data = $database->get_all("
SELECT tag, FLOOR(LN(LN(count - :tag_min1 + 1)+1)*150)/200 AS scaled, count
FROM tags
WHERE count >= :tag_min2
ORDER BY $order_by
LIMIT :limit",
array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count));
break;
case 'r':
$relevant_tags = array_diff($image->get_tag_array(),$ignore_tags);
if(count($relevant_tags) == 0) {
@ -113,6 +101,18 @@ class TagEditCloud extends Extension {
LIMIT :limit",
array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count));
break;
case 'a':
case 'p':
default:
$order_by = $sort_method == 'a' ? "tag" : "count DESC";
$tag_data = $database->get_all("
SELECT tag, FLOOR(LN(LN(count - :tag_min1 + 1)+1)*150)/200 AS scaled, count
FROM tags
WHERE count >= :tag_min2
ORDER BY $order_by
LIMIT :limit",
array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count));
break;
}
$counter = 1;

View file

@ -220,7 +220,7 @@ class Wiki extends Extension {
/**
* @param string $title
* @param int|null $revision
* @param integer $revision
* @return WikiPage
*/
private function get_page($title, $revision=-1) {

View file

@ -114,6 +114,9 @@ do_install();
// utilities {{{
// TODO: Can some of these be pushed into "core/util.inc.php" ?
/**
* @return int
*/
function check_gd_version() {
$gdversion = 0;
@ -129,6 +132,9 @@ function check_gd_version() {
return $gdversion;
}
/**
* @return int
*/
function check_im_version() {
$convert_check = exec("convert");
@ -469,6 +475,12 @@ EOD;
echo "\n";
} // }}}
/**
* @param boolean $isPDO
* @param string $errorMessage1
* @param string $errorMessage2
* @param integer $exitCode
*/
function handle_db_errors(/*bool*/ $isPDO, /*str*/ $errorMessage1, /*str*/ $errorMessage2, /*int*/ $exitCode) {
$errorMessage1Extra = ($isPDO ? "Please check and ensure that the database configuration options are all correct." : "Please check the server log files for more information.");
print <<<EOD

View file

@ -16,7 +16,7 @@ if(is_null(User::by_name("demo"))) {
$userPage->onUserCreation(new UserCreationEvent("test", "test", ""));
}
abstract class ShimmiePHPUnitTestCase extends PHPUnit_Framework_TestCase {
abstract class ShimmiePHPUnitTestCase extends \PHPUnit_Framework_TestCase {
protected $backupGlobalsBlacklist = array('database', 'config');
private $images = array();

View file

@ -164,7 +164,7 @@ class Layout {
$flash = $page->get_cookie("flash_message");
$flash_html = "";
if($flash) {
if(!empty($flash)) {
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
}
@ -242,7 +242,7 @@ EOD;
/**
* @param string $link
* @param null|string $desc
* @param array $pages_matched
* @param string[] $pages_matched
* @return null|string
*/
public function navlinks($link, $desc, $pages_matched) {