Comments (7)
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.
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.
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.
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.
@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.
@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.
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)
- PHP 7.4 Could not execute Model::__construct() HOT 2
- Code comments lead to non-existing documentation
- Feature-Request: Jump from before() to after() and skip controller action() HOT 7
- Replace Kohana's ORM with Laravel's or use Laravel's ORM with Kohana (code provided) HOT 6
- Module "image" is broken for watermark() since updated to Imagick 3.6.0
- Koseven for PHP 8.1 HOT 5
- PHP 8.1 compatibility HOT 3
- Kohana to Koseven Porting Help HOT 5
- Porting Hooks From Old Kohana HOT 1
- PHP 8.3 HOT 12
- Arr::path results in error
- Request::user_agent(array('platform')) shows wrong and empty results
- Difference between Auth_Bcrypt and Auth_ORM for logged_in() function
- proxy/ssrf issue HOT 1
- fix documentation for security please
- [PHP 8.0] Valid::numeric should be locale independent
- as_array() with type casting: DB::query(Database::SELECT, '...')->execute()->as_array('id', array('id'=>'int')); HOT 1
- Question: Is there a PHP checker like PHPStan that works with Kohana? HOT 3
- Dependabot alerts for jquery.min.js in modules/userguide HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koseven.