From 7dcddaddcffb69c58800d2fb3f6f169791cab1f7 Mon Sep 17 00:00:00 2001 From: John James Jacoby Date: Thu, 10 Mar 2022 15:12:11 -0600 Subject: [PATCH] Table: add _clone() shim from Sugar Calendar. (#131) For PHP 5.6 compatibility. Fixes #38. --- src/Database/Table.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Database/Table.php b/src/Database/Table.php index 6a12b4d..9776fba 100644 --- a/src/Database/Table.php +++ b/src/Database/Table.php @@ -160,6 +160,24 @@ public function __construct() { } } + /** + * Compatibility for clone() method for PHP versions less than 7.0. + * + * See: https://github.com/sugarcalendar/core/issues/105 + * + * This shim will be removed at a later date. + * + * @since 2.0.20 + * + * @param string $function + * @param array $args + */ + public function __call( $function = '', $args = array() ) { + if ( 'clone' === $function ) { + call_user_func_array( array( $this, '_clone' ), $args ); + } + } + /** Abstract **************************************************************/ /** @@ -488,7 +506,7 @@ public function delete_all() { * * @return bool */ - public function clone( $new_table_name = '' ) { + public function _clone( $new_table_name = '' ) { // Get the database interface $db = $this->get_db();