-
admin0
Junior Member
-
Posts: 30
Threads: 12
Joined: Jun 2018
Reputation:
0
Hi,
I am using the HMVC and on php7.3, I get this:
Code: A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: MX/Router.php
Line Number: 239
Backtrace:
File: /web/application/third_party/MX/Router.php
Line: 239
Function: strpos
File: /web/application/third_party/MX/Router.php
Line: 101
Function: _set_default_controller
File: /web/public/index.php
Line: 315
Function: require_once
Though this is a CI forum, I do not know how to ask help from the HMVC page: https://bitbucket.org/wiredesignz/codeig...sions-hmvc
If someone knows what to do, please let me know.
Thanks
-
InsiteFX
Super Moderator
-
Posts: 6,639
Threads: 337
Joined: Oct 2014
Reputation:
243
You can try this and see if it works, not tested I do not have HMVC installed
right now.
PHP Code: public function set_class($class) { $pos = strpos($class, $suffix); if ($pos === FALSE) { $class .= $suffix; }
parent::set_class($class); }
Let me know how it turns out.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
-
admin0
Junior Member
-
Posts: 30
Threads: 12
Joined: Jun 2018
Reputation:
0
Hi,
$pos = strpos($class, $suffix); still returns the same error:
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior.
This seems to work, but not sure how this will affect ..
$pos = strpos($class, chr($suffix));
-
skunkbad
Senior Citizen
-
Posts: 1,300
Threads: 63
Joined: Oct 2014
Reputation:
86
I'm looking through the HMVC code, and I see nowhere that controller_suffix is set to a config item. The way CodeIgniter works, if a config item doesn't exist, then it's NULL or FALSE (doesn't matter). So, that being the case, if the needle is a boolean or null, then you could do something like this:
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if( $suffix && strpos($class, $suffix) === FALSE) { $class .= $suffix; }
parent::set_class($class); }
You could probably also cast $suffix to string, which may be appropriate if controller_suffix was meant to be an empty string:
PHP Code: $suffix = (string) $this->config->item('controller_suffix');
I don't use HMVC, so I can't test this, but if I'm right that the config item for controller_suffix is not set anywhere, then this is probably your answer.
-
gtozadori
Newbie
-
Posts: 3
Threads: 0
Joined: Sep 2017
Reputation:
0
Hi,
I was having the same problem, I made changes similar to those that were indicated, the only difference was that I added the controller_suffix in the configuration parameters, because when I looked at the problem earlier this week, I noticed that it did not exist.
But that's it, it worked!
-
daycry
Newbie
-
Posts: 7
Threads: 1
Joined: Mar 2019
Reputation:
1
(12-14-2018, 12:33 PM)skunkbad Wrote: I'm looking through the HMVC code, and I see nowhere that controller_suffix is set to a config item. The way CodeIgniter works, if a config item doesn't exist, then it's NULL or FALSE (doesn't matter). So, that being the case, if the needle is a boolean or null, then you could do something like this:
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if( $suffix && strpos($class, $suffix) === FALSE) { $class .= $suffix; }
parent::set_class($class); }
You could probably also cast $suffix to string, which may be appropriate if controller_suffix was meant to be an empty string:
PHP Code: $suffix = (string) $this->config->item('controller_suffix');
I don't use HMVC, so I can't test this, but if I'm right that the config item for controller_suffix is not set anywhere, then this is probably your answer.
Maybe run this:
$suffix = $this->config->item('subclass_prefix');
-
synanhero
Newbie
-
Posts: 1
Threads: 0
Joined: Feb 2016
Reputation:
0
08-05-2019, 06:19 AM
(This post was last modified: 10-17-2019, 01:38 PM by synanhero.)
just change application/third_party/MX/Router.php line 239
from this
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if (strpos($class, $suffix) === FALSE) { $class .= $suffix; } parent::set_class($class); }
to this
PHP Code: public function set_class($class) { $suffix = (string) $this->config->item('controller_suffix'); if ($suffix && strpos(strval($class), $suffix) === FALSE) { $class .= $suffix; } parent::set_class($class); }
tested
-
TamasD
Junior Member
-
Posts: 17
Threads: 7
Joined: Dec 2016
Reputation:
0
(08-05-2019, 06:19 AM)synanhero Wrote: just change application/third_party/MX/Router.php line 239
from this
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if (strpos($class, $suffix) === FALSE) { $class .= $suffix; } parent::set_class($class); }
to this
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if (strpos(strval($class), $suffix) === FALSE) { $class .= $suffix; } parent::set_class($class); }
tested
To me this worked but with a little tweak:
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); // if (strpos(strval($class), $suffix) === FALSE) if( $suffix && strpos($class, $suffix) === FALSE) { $class .= $suffix; } parent::set_class($class); }
-
abacoin
Newbie
-
Posts: 1
Threads: 0
Joined: Sep 2019
Reputation:
0
(12-14-2018, 12:33 PM)skunkbad Wrote: I'm looking through the HMVC code, and I see nowhere that controller_suffix is set to a config item. The way CodeIgniter works, if a config item doesn't exist, then it's NULL or FALSE (doesn't matter). So, that being the case, if the needle is a boolean or null, then you could do something like this:
PHP Code: public function set_class($class) { $suffix = $this->config->item('controller_suffix'); if( $suffix && strpos($class, $suffix) === FALSE) { $class .= $suffix; }
parent::set_class($class); }
You could probably also cast $suffix to string, which may be appropriate if controller_suffix was meant to be an empty string:
PHP Code: $suffix = (string) $this->config->item('controller_suffix');
I don't use HMVC, so I can't test this, but if I'm right that the config item for controller_suffix is not set anywhere, then this is probably your answer.
THANK YOU !!!
JUST CHANGE THIS LINE
if( $suffix && strpos($class, $suffix) === FALSE)
AND FIX IT !!!!
|