Giter Site home page Giter Site logo

Comments (7)

timhj avatar timhj commented on June 11, 2024

Is your language config file returning an Array or StdClass? If an stdclass/object, return an array.

The config loader uses Arr::Path, which would have started failing on objects in PHP 7.4.x. As a quick fix to get things working with 7.4, the Arr::path behaviour was changed to work only with arrays (and not traversable objects). It now returns NULL if an object is passed so could be the cause of your issue. Sorry if that's your issue, it was my PR and a really quick fix to make the framework load with PHP 7.4 - realising now, it was a breaking change.

As a workaround - If your language config file is a stdclass/object, return it as an array and it should work.

from koseven.

timhj avatar timhj commented on June 11, 2024

Actually - it looks like the expected behaviour with Arrays using Path was removed in this commit before my PR.
a58959e#r66381687

I'll drop a fix in and look to get it merged to resolve.

from koseven.

ajuszczyk avatar ajuszczyk commented on June 11, 2024

Thanks @timhj
I applied your fix but still getting nulls.
Here is the code:
config/language.php

<?php defined('SYSPATH') or die('No direct script access.');
 
return array(
    'language' => 'english',
    'language_abbr' => 'en-gb',
    'lang_uri_abbr' => array("pl-pl" => "polish", "en-gb" => "english", "en-us" => "us_english"),
    'lang_ignore' => 'xx', 
    'lang_desc' => array("en-us" => "US English version", "en-gb" => "English version", "pl-pl"=>"Polish version"),
);

and the bootstrap.php

/**
 * Load language conf
 */
$langs 		= Kohana::$config->load('language.lang_uri_abbr');
$default_lang 	= Kohana::$config->load('language.language_abbr');
$lang_ignore	= Kohana::$config->load('language.lang_ignore');

any of those give back null with your fix applied, I'm afraid.

from koseven.

ajuszczyk avatar ajuszczyk commented on June 11, 2024

In addition this is what I'm getting back with Kohana::$config->load('language')

object(Config_Group)[6]
  protected '_parent_instance' => 
    object(Config)[3]
      protected '_sources' => 
        array (size=1)
          0 => 
            object(Config_File)[5]
              ...
      protected '_groups' => 
        array (size=1)
          'language' => 
            object(Config_Group)[6]
              ...
  protected '_group_name' => string 'language' (length=8)
  private 'storage' (ArrayObject) => 
    array (size=5)
      'language' => string 'english' (length=7)
      'language_abbr' => string 'en-gb' (length=5)
      'lang_uri_abbr' => 
        array (size=3)
          'pl-pl' => string 'polish' (length=6)
          'en-gb' => string 'english' (length=7)
          'en-us' => string 'us_english' (length=10)
      'lang_ignore' => string 'xx' (length=2)
      'lang_desc' => 
        array (size=3)
          'en-us' => string 'US English version' (length=18)
          'en-gb' => string 'English version' (length=15)
          'pl-pl' => string 'Polish version' (length=14)

from koseven.

timhj avatar timhj commented on June 11, 2024

@ajuszczyk - I mentioned two fixes, did you apply this one: https://github.com/koseven/koseven/pull/467/files ?

It looks like it should solve your issue as you're getting individual values from the config array, which would not have worked.

from koseven.

ajuszczyk avatar ajuszczyk commented on June 11, 2024

@timhj thanks, I have only applied the fix you mentioned (https://github.com/koseven/koseven/pull/467/files) - 1 line of code change. I'm not sure what the other fix is, I'm afraid.
I'm getting the same results with or without the fix.

from koseven.

ajuszczyk avatar ajuszczyk commented on June 11, 2024

Hi @timhj
The only way to fix the issue for me was to change line 95 in that file (Arr.php):
if ( ! is_array($array))
to
if ( ! Arr::is_array($array))

And then the line 104 can stay as:
if (is_object($array) AND property_exists($array, $path))

The original kohava doc says:
https://kohana.top/3.4/guide-api/Arr#is_array
Test if a value is an array with an additional check for array-like objects

// Returns true
Arr::is_array([]);
Arr::is_array(new ArrayObject);

It is litelarly the method above public static function path(...) code it that file :)

Maybe using is_iterable() would be a better solution here?

from koseven.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.