0

i have joomla site on local server with php5.4 and it works fine but when i upload it to live server it the all site gives error " unexpected [ " on line 491 in example.php when commenting that line it works good but i am not sure if this will make a problem in some extension or not.

line 491 which gives that error

$hash = md5(json_encode([$reftable,$reffield, $refids, $language]));

the complete function code containing this line is:

public function getRawFieldTranslations($reftable,$reffield, $refids, $language)
{

    static $cache = array();

    $hash = md5(json_encode([$reftable,$reffield, $refids, $language]));

    if (!isset($cache[$hash])) {
        $db      = JFactory::getDbo();
        $dbQuery = $db->getQuery(true)
            ->select($db->quoteName('value'))
            ->from('#__falang_content fc')
            ->where('fc.reference_id = ' . $db->quote($refids))
            ->where('fc.language_id = ' . (int) $language)
            ->where('fc.published = 1')
            ->where('fc.reference_field = ' . $db->quote($reffield))
            ->where('fc.reference_table = ' . $db->quote($reftable));

        $db->setQuery($dbQuery);
        $result  = $db->loadResult();

        //$cache[$hash] don't like null value
        if (!empty($result)){
           $cache[$hash] = $result;
        } else {
           $cache[$hash] = '';
        }

    }

    return $cache[$hash];
}

so, hot exactly to modify this code to work with php5.3

mohamed
  • 1
  • 1
  • Shorthand arrays were introduced in 5.4. You need to build the array inside json_encode() the old fashioned way. https://stackoverflow.com/questions/4271874/shorthand-for-arrays-is-there-a-literal-syntax-like-or – Paul Abbott May 01 '18 at 22:28
  • thank you for your help $pulp = array(); $hash = md5(json_encode($pulp)); is that correct – mohamed May 01 '18 at 22:49

0 Answers0