Welcome Guest, Not a member yet? Register   Sign In
HMVC broken in php 7.3 -- help
#1

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
Reply
#2

posting the code in question as well:


Quote:public function set_class($class)
{
$suffix = $this->config->item('controller_suffix');
if (strpos($class, $suffix) === FALSE)  // THIS LINE
{
$class .= $suffix;
}
parent:Confusedet_class($class);
}
Reply
#3

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 )
Reply
#4

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));
Reply
#5

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.
Reply
#6

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! Wink
Reply
#7

(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');
Reply
#8

(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  Angel
Reply
#9

(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  Angel

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);
 
   
Reply
#10

(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 !!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB