From a80d64cfb872b2cfc16a516c0a26e4b68984a289 Mon Sep 17 00:00:00 2001 From: weryques Date: Thu, 2 Aug 2018 08:57:32 -0300 Subject: [PATCH] Fixes incompatibilities with older versions of PHP FILE: tainacan/src/importer/class-tainacan-importer.php ----------------------------------------------------------------------------------- FOUND 3 ERRORS AFFECTING 2 LINES ----------------------------------------------------------------------------------- 603 | ERROR | 'int' type declaration is not present in PHP version 5.6 or earlier 616 | ERROR | 'int' type declaration is not present in PHP version 5.6 or earlier 616 | ERROR | 'int' type declaration is not present in PHP version 5.6 or earlier ----------------------------------------------------------------------------------- FILE: tainacan/src/classes/class-tainacan-elastic-press.php ---------------------------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES ---------------------------------------------------------------------------------------- 16 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and | | prohibited since PHP 5.4 24 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and | | prohibited since PHP 5.4 ---------------------------------------------------------------------------------------- FILE: tainacan/src/classes/class-tainacan-bulk-edit.php ---------------------------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES ---------------------------------------------------------------------------------------- 78 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and | | prohibited since PHP 5.4 85 | ERROR | Using a call-time pass-by-reference is deprecated since PHP 5.3 and | | prohibited since PHP 5.4 ---------------------------------------------------------------------------------------- --- src/classes/class-tainacan-bulk-edit.php | 4 ++-- src/classes/class-tainacan-elastic-press.php | 4 ++-- src/importer/class-tainacan-importer.php | 4 ++-- verify_compat.sh | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/classes/class-tainacan-bulk-edit.php b/src/classes/class-tainacan-bulk-edit.php index b6c0a074e..4cf646312 100644 --- a/src/classes/class-tainacan-bulk-edit.php +++ b/src/classes/class-tainacan-bulk-edit.php @@ -75,14 +75,14 @@ class Bulk_Edit { add_filter('posts_pre_query', '__return_empty_array'); // this adds the meta key and meta value to the SELECT query so it can be used directly in the INSERT below - add_filter('posts_fields_request', [&$this, 'add_fields_to_query'], 10, 2); + add_filter('posts_fields_request', [$this, 'add_fields_to_query'], 10, 2); $itemsRepo = Repositories\Items::get_instance(); $params['query']['fields'] = 'ids'; $items_query = $itemsRepo->fetch($params['query'], $params['collection_id']); remove_filter('posts_pre_query', '__return_empty_array'); - remove_filter('posts_fields_request', [&$this, 'add_fields_to_query']); + remove_filter('posts_fields_request', [$this, 'add_fields_to_query']); $wpdb->query( "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) {$items_query->request}" ); diff --git a/src/classes/class-tainacan-elastic-press.php b/src/classes/class-tainacan-elastic-press.php index 880148473..4f8c16f14 100644 --- a/src/classes/class-tainacan-elastic-press.php +++ b/src/classes/class-tainacan-elastic-press.php @@ -13,7 +13,7 @@ namespace Tainacan; class Elastic_Press { function __construct($ajax_query=false) { - add_action('init', [&$this, 'init']); + add_action('init', [$this, 'init']); } @@ -21,7 +21,7 @@ class Elastic_Press { if (!class_exists('EP_API')) { return; // ElasticPress not active } - add_filter('tainacan_fetch_args', [&$this, 'filter_args'], 10, 2); + add_filter('tainacan_fetch_args', [$this, 'filter_args'], 10, 2); } function filter_args($args, $type) { diff --git a/src/importer/class-tainacan-importer.php b/src/importer/class-tainacan-importer.php index 9756c9d0c..b0af6efdd 100644 --- a/src/importer/class-tainacan-importer.php +++ b/src/importer/class-tainacan-importer.php @@ -600,7 +600,7 @@ abstract class Importer { * the current progress of the process. * */ - protected function set_current_step_total(int $value) { + protected function set_current_step_total($value) { $this->set_step_total($this->get_current_step(), $value); } @@ -613,7 +613,7 @@ abstract class Importer { * the current progress of the process. * */ - protected function set_step_total(int $step, int $value) { + protected function set_step_total($step, $value) { $steps = $this->get_steps(); if (isset($steps[$step]) && is_array($steps[$step])) { $steps[$step]['total'] = $value; diff --git a/verify_compat.sh b/verify_compat.sh index a99123e2c..d88d4f248 100755 --- a/verify_compat.sh +++ b/verify_compat.sh @@ -5,4 +5,6 @@ echo 'W is Warning' echo 'E is Error' ./src/vendor/bin/phpcs -p . --standard=PHPCompatibility --extensions=php --ignore=*/node_modules/*,*/src/vendor/* --report-file=./report.txt --runtime-set testVersion 5.6 +echo 'Done' +echo 'Results are in ./report.txt'