Skip to content

Commit

Permalink
Merge pull request #53 from rohit053/v1.3.0
Browse files Browse the repository at this point in the history
V1.3.0 released: Compatible with php 7.x.x
  • Loading branch information
webkul authored Oct 18, 2018
2 parents 035f427 + 449469b commit a38e17d
Show file tree
Hide file tree
Showing 45 changed files with 443 additions and 267 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
####################################
# V1.3.0
####################################

## Added Features:

[+] CO : Qloapps is compatible with php 7.x.x .


## Improved/changed features:

[+] CO : "create demo data or not" option improved for Qloapps demo data .
[+] CO : System compatibility check for Qloapps installation improved .


####################################
# V1.2.0
####################################
Expand Down
51 changes: 49 additions & 2 deletions classes/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ public static function getDefaultTests()
'config_dir' => 'config',
'files' => false,
'mails_dir' => 'mails',
'curl' => false,
'soap' => false,
'simplexml' => false,
'memory_limit' => false,
'upload_max_filesize' => false,
'max_execution_time' => false,
));
}

return $tests;
}

Expand Down Expand Up @@ -139,7 +144,7 @@ public static function run($ptr, $arg = 0)

public static function test_phpversion()
{
return version_compare(substr(phpversion(), 0, 5), '5.2.0', '>=');
return version_compare(substr(phpversion(), 0, 5), '5.4.0', '>=');
}

public static function test_new_phpversion()
Expand All @@ -157,6 +162,21 @@ public static function test_pdo_mysql()
return extension_loaded('pdo_mysql');
}

public static function test_curl()
{
return extension_loaded('curl');
}

public static function test_soap()
{
return extension_loaded('soap');
}

public static function test_simplexml()
{
return extension_loaded('simplexml');
}

public static function test_magicquotes()
{
return !get_magic_quotes_gpc();
Expand All @@ -167,6 +187,33 @@ public static function test_upload()
return ini_get('file_uploads');
}

public static function test_upload_max_filesize()
{
$upload_max_filesize = preg_replace('/[^0-9\.-]/', '', ini_get('upload_max_filesize'));
if ($upload_max_filesize >= 16) {
return true;
}
return false;
}

public static function test_max_execution_time()
{
$max_execution_time = preg_replace('/[^0-9\.-]/', '', ini_get('max_execution_time'));
if ($max_execution_time == 0 || $max_execution_time >= 500) {
return true;
}
return false;
}

public static function test_memory_limit()
{
$memoryLimit = preg_replace('/[^0-9\.-]/', '', ini_get('memory_limit'));
if ($memoryLimit == -1 || $memoryLimit >= 128) {
return true;
}
return false;
}

public static function test_fopen()
{
return ini_get('allow_url_fopen');
Expand Down
21 changes: 15 additions & 6 deletions classes/ObjectModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
/** @var int Shop ID */
protected $id_shop = null;

/** @var array|null List of shop IDs */
public $id_shop_list = null;
/** @var array List of shop IDs */
public $id_shop_list = array();

/** @var bool */
protected $get_shop_from_context = true;
Expand Down Expand Up @@ -751,7 +751,7 @@ public function delete()
// Remove association to multishop table
if (Shop::isTableAssociated($this->def['table'])) {
$id_shop_list = Shop::getContextListShopID();
if (count($this->id_shop_list)) {
if (count($this->id_shop_list) > 0) {
$id_shop_list = $this->id_shop_list;
}

Expand Down Expand Up @@ -1146,9 +1146,18 @@ public function validateController($htmlentities = true)
// Checking for fields validity
// Hack for postcode required for country which does not have postcodes
if (!empty($value) || $value === '0' || ($field == 'postcode' && $value == '0')) {
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required'])) {
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
} else {

$validation_error = false;
if (isset($data['validate'])) {
$data_validate = $data['validate'];
if (!Validate::$data_validate($value) && (!empty($value) || $data['required'])) {
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).
'</b> '.Tools::displayError('is invalid.');
$validation_error = true;
}
}

if (!$validation_error) {
if (isset($data['copy_post']) && !$data['copy_post']) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static function getModuleTranslation($module, $string, $source, $sprintf
$default_key = strtolower('<{'.$name.'}prestashop>'.$source).'_'.$key;

if ('controller' == substr($source, -10, 10)) {
+ $file = substr($source, 0, -10);
$file = substr($source, 0, -10);
$current_key_file = strtolower('<{'.$name.'}'._THEME_NAME_.'>'.$file).'_'.$key;
$default_key_file = strtolower('<{'.$name.'}prestashop>'.$file).'_'.$key;
}
Expand Down
18 changes: 12 additions & 6 deletions classes/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,25 @@ public function setSavePath($value)

public function getPostMaxSizeBytes()
{
$post_max_size = ini_get('post_max_size');
$bytes = trim($post_max_size);
$last = strtolower($post_max_size[strlen($post_max_size) - 1]);
$postMaxSize = ini_get('post_max_size');
$bytes = (int) trim($postMaxSize);
$last = strtolower($postMaxSize[strlen($postMaxSize) - 1]);

switch ($last) {
case 'g': $bytes *= 1024;
case 'm': $bytes *= 1024;
case 'k': $bytes *= 1024;
case 'g':
$bytes *= 1024;
// no break
case 'm':
$bytes *= 1024;
// no break
case 'k':
$bytes *= 1024;
}

if ($bytes == '') {
$bytes = null;
}

return $bytes;
}

Expand Down
13 changes: 8 additions & 5 deletions classes/controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function __construct()
*/
public function initBreadcrumbs($tab_id = null, $tabs = null)
{
if (is_array($tabs) || count($tabs)) {
if (is_array($tabs)) {
$tabs = array();
}

Expand Down Expand Up @@ -1374,13 +1374,15 @@ protected function processUpdateOptions()
if (isset($values['type']) && in_array($values['type'], array('textLang', 'textareaLang'))) {
foreach ($languages as $language) {
if (Tools::getValue($field.'_'.$language['id_lang']) && isset($values['validation'])) {
if (!Validate::$values['validation'](Tools::getValue($field.'_'.$language['id_lang']))) {
$values_validation = $values['validation'];
if (!Validate::$values_validation(Tools::getValue($field.'_'.$language['id_lang']))) {
$this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
}
}
}
} elseif (Tools::getValue($field) && isset($values['validation'])) {
if (!Validate::$values['validation'](Tools::getValue($field))) {
$values_validation = $values['validation'];
if (!Validate::$values_validation(Tools::getValue($field))) {
$this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
}
}
Expand Down Expand Up @@ -3246,7 +3248,7 @@ public function getModulesList($filter_modules_list)
$filter_modules_list = array($filter_modules_list);
}

if (!count($filter_modules_list)) {
if (is_null($filter_modules_list) || !count($filter_modules_list)) {
return false;
} //if there is no modules to display just return false;

Expand Down Expand Up @@ -3639,7 +3641,8 @@ protected function validateField($value, $field)
if (isset($field['validation'])) {
$valid_method_exists = method_exists('Validate', $field['validation']);
if ((!isset($field['empty']) || !$field['empty'] || (isset($field['empty']) && $field['empty'] && $value)) && $valid_method_exists) {
if (!Validate::$field['validation']($value)) {
$field_validation = $field['validation'];
if (!Validate::$field_validation($value)) {
$this->errors[] = Tools::displayError($field['title'].' : Incorrect value');
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion classes/db/DbQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ public function select($fields)
public function from($table, $alias = null)
{
if (!empty($table)) {
if (empty($this->query['from'])) {
$this->query['from'] = array();
}
$this->query['from'][] = '`'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '');
}

return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/helper/HelperList.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function displayListContent()
$position_group_identifier = Category::getRootCategory()->id;
}

$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
$positions = array_map(function($elem) { return (int)($elem['position']); }, $this->_list);
sort($positions);
}

Expand Down
7 changes: 6 additions & 1 deletion classes/helper/HelperOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function generateOptions($option_list)

// Fill values for all languages for all lang fields
if (substr($field['type'], -4) == 'Lang') {
$field['value'] = array();
foreach ($languages as $language) {
if ($field['type'] == 'textLang') {
$value = Tools::getValue($key.'_'.$language['id_lang'], Configuration::get($key, $language['id_lang']));
Expand All @@ -166,7 +167,11 @@ public function generateOptions($option_list)
} elseif ($field['type'] == 'selectLang') {
$value = Configuration::get($key, $language['id_lang']);
}
$field['languages'][$language['id_lang']] = $value;
if (isset($value)) {
$field['languages'][$language['id_lang']] = $value;
} else {
$field['languages'][$language['id_lang']] = '';
}
$field['value'][$language['id_lang']] = $this->getOptionValue($key.'_'.strtoupper($language['iso_code']), $field);
}
}
Expand Down
3 changes: 1 addition & 2 deletions classes/module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,7 @@ public static function getModulesOnDisk($use_config = false, $logged_on_addons =
$module->interest = 0;
}
}
usort($module_list, create_function('$a,$b', 'return strnatcasecmp($a->displayName, $b->displayName);'));
usort($module_list, function ($a, $b) { return strnatcasecmp($a->displayName, $b->displayName); });
if ($errors) {
if (!isset(Context::getContext()->controller) && !Context::getContext()->controller->controller_name) {
echo '<div class="alert error"><h3>'.Tools::displayError('The following module(s) could not be loaded').':</h3><ol>';
Expand Down
3 changes: 2 additions & 1 deletion classes/webservice/WebserviceOutputBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ protected function renderField($object, $ws_params, $field_name, $field, $depth)
unset($field['xlink_resource']);
}
} elseif (isset($field['getter']) && $object != null && method_exists($object, $field['getter'])) {
$field['value'] = $object->$field['getter']();
$field_getter = $field['getter'];
$field['value'] = $object->$field_getter();
} elseif (!isset($field['value'])) {
$field['value'] = $object->$field_name;
}
Expand Down
5 changes: 3 additions & 2 deletions classes/webservice/WebserviceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static function getResources()
'customizations' => array('description' => 'Customization values', 'class' => 'Customization'),
);

// Code from Prestashop 1.7.0.2
// Code from Prestashop 1.7.0.2
$extra_resources = Hook::exec('addWebserviceResources', array('resources' => $resources), null, true, false);
if (is_array($extra_resources) && count($extra_resources)) {
foreach ($extra_resources as $new_resources) {
Expand Down Expand Up @@ -1439,7 +1439,8 @@ protected function saveEntityFromXml($successReturnCode)
$this->setError(400, 'parameter "'.$fieldName.'" not writable. Please remove this attribute of this XML', 93);
return false;
} else {
$object->$fieldProperties['setter']((string)$attributes->$fieldName);
$setter = $fieldProperties['setter'];
$object->$setter((string)$attributes->$fieldName);
}
} elseif (property_exists($object, $sqlId)) {
$object->$sqlId = (string)$attributes->$fieldName;
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function checkToken()
*
* @return bool
*/
public function viewAccess()
public function viewAccess($disable = false)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public function initContent()
}

$accessories = $this->product->getAccessories($this->context->language->id);
if ($this->product->cache_is_pack || count($accessories)) {
if ($this->product->cache_is_pack || ($accessories && count($accessories))) {
$this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
if ($this->product->customizable) {
Expand Down
4 changes: 2 additions & 2 deletions install/classes/controllerConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ final public static function execute($argc, $argv)
}
exit;
}

$errors = Datas::getInstance()->getAndCheckArgs($argv);
if (Datas::getInstance()->show_license) {
echo strip_tags(file_get_contents(_PS_INSTALL_PATH_.'theme/views/license_content.phtml'));
Expand Down Expand Up @@ -114,7 +114,7 @@ final public function __construct($step)
{
$this->step = $step;
$this->datas = Datas::getInstance();

// Set current language
$this->language = InstallLanguages::getInstance();
if (!$this->datas->language) {
Expand Down
13 changes: 12 additions & 1 deletion install/controllers/http/process.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,18 @@ public function processInstallModules()
{
$this->initializeContext();

$result = $this->model_install->installModules(Tools::getValue('module'));
// code to populate database of modules
if ($this->session->install_type == 'full') {
$populateData = 1;
} else {
$populateData = 0;
}
// extra parameter sent to populate module data or not
$result = $this->model_install->installModules(
Tools::getValue('module'),
$populateData
);

if (!$result || $this->model_install->getErrors()) {
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
}
Expand Down
10 changes: 8 additions & 2 deletions install/controllers/http/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ public function display()
'title' => $this->l('Required PHP parameters'),
'success' => 1,
'checks' => array(
'phpversion' => $this->l('PHP 5.1.2 or later is not enabled'),
'phpversion' => $this->l('Minimum PHP 5.4.0 or later is required'),
'upload' => $this->l('Cannot upload files'),
'system' => $this->l('Cannot create new files and folders'),
'gd' => $this->l('GD library is not installed'),
'mysql_support' => $this->l('MySQL support is not activated')
'mysql_support' => $this->l('MySQL support is not activated'),
'curl' => $this->l('Curl extension is not loaded'),
'soap' => $this->l('SOAP extension is not loaded'),
'simplexml' => $this->l('SimpleXml extension is not loaded'),
'upload_max_filesize' => $this->l('In the PHP configuration set memory_limit to minimum 128M'),
'max_execution_time' => $this->l('In the PHP configuration set max_execution_time to minimum 500'),
'memory_limit' => $this->l('In the PHP configuration set upload_max_filesize to minimum 16M'),
)
),
array(
Expand Down
2 changes: 1 addition & 1 deletion install/install_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
*/

define('_PS_INSTALL_VERSION_', '1.6.1.1');
define('_QLO_INSTALL_VERSION_', '1.2.0');
define('_QLO_INSTALL_VERSION_', '1.3.0');
Loading

0 comments on commit a38e17d

Please sign in to comment.