InvoicePlane 1.5.9 router.php error

Hi
This error is showing on all pages.

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: 224

Backtrace:

File: C:\xampp\htdocs\InvoicePlane\application\third_party\MX\Router.php
Line: 224
Function: strpos

File: C:\xampp\htdocs\InvoicePlane\application\third_party\MX\Router.php
Line: 71
Function: set_class

File: C:\xampp\htdocs\InvoicePlane\index.php
Line: 325
Function: require_once

This is code which seems to have some issue

public function set_class($class)
{
    $suffix = $this->config->item('controller_suffix');
    if (strpos($class, $suffix) === false) {
        $class .= $suffix;
    }
    parent::set_class($class);
}

Have U gus have any ideas? :slight_smile: THX in advantage U R Great!
PHP.7.3 Windows

Some solution coud be quote out
//if (strpos($class, $suffix) === false) {
and add this
if (strncmp($class, $suffix, strlen($suffix)) === 0) {

But I don’t know what else and if it gonna do some bugs.
Error message seems to dissapear.

Hello @Mario

An easy solution can also to check if $suffix exists by doing this

if ($suffix && strpos($class, $suffix) === false) {
1 Like

Guess this issue is related to this one:

https://community2.invoiceplane.com/t/topic/5348/13

Maybe the solution over there also fits here.
If so we have to evaluate which is better. And then include the better one to the core to fix PHP 7.3 Support

1 Like

Have you got any solution?

@kasimross the solution is to take a look at this topic:
https://community2.invoiceplane.com/t/topic/5348/13
anything related to PHP 7.2+7.3 and InvoicePlane 1.5.9 is either solved by applying that fix from that topic

hey thanks for sharing the solution… i was also having similar issue.
best regards!!!

Replace line no. 221- 228 by the below code

public function set_class($class)
{
    $suffix = (string) $this->config->item('controller_suffix'); 
    parent::set_class($class);
}

Thanks for the solution! :blush: