? Failure

User tests: Successful: Unsuccessful:

avatar fanno
fanno
15 Jul 2016

Pull Request for Issue # .

Summary of Changes

Testing Instructions

…edirect function.

if ($url[0] == '/')... generates an error

PHP Notice: Uninitialized string offset: 0 in .../libraries/joomla/application/web.php on line 509

adding a check for empty $url fixes that.

not sure if this is correct way to add it.

avatar fanno fanno - open - 15 Jul 2016
avatar brianteeman brianteeman - change - 23 Jul 2016
Category Libraries
avatar bertmert
bertmert - comment - 23 Jul 2016

@fanno
Could you please provide some testing instructions.
Where can I trigger the notice in Joomla core?
Wouldn't it be better if extensions check the URL before they send it to redirect()?

avatar brianteeman brianteeman - change - 3 Aug 2016
Status New Information Required
avatar brianteeman
brianteeman - comment - 12 Aug 2016

@fanno Please can you respond to the question from @bertmert or this will be closed in a few weeks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11151.

avatar fanno
fanno - comment - 13 Aug 2016

sorry i have been busy.

Could you please provide some testing instructions.

i am not sure what you mean by testing instructions ?

redirect("") would do it.

Where can I trigger the notice in Joomla core?

I am still trying to trace the actual cause on my setup, and i am still unable to locate where it is happening. i cant figure out if it is comming from my code or from code in some other 3rd party code that we use.

Wouldn't it be better if extensions check the URL before they send it to redirect()?
yes that would ofcause be better, tho not everyone know what they are doing., i only created this to prevent "unforseen" erros. i like to think i know just a little bit about what i am doing. i am no pro ofcause,

P.S. this wont "FIX" my issue as such. but it will fix potentual issue with redirect. again i am just reporting it because an error can happen.

if no "fixing" the url and just redirct to index. then pehaps "throw" and exception with invalid parameter or something like that.

avatar bertmert
bertmert - comment - 14 Aug 2016

Testing instructions

You always must provide some error producing code and describe where to insert it for testing or describe a way (e.g. settings in the back-end (error reporting: maximum) and so on) to reproduce the error/issue you described. So anybody can test the behavior before and after applying your PR. (Most people use Joomla Patchtester Component to test PRs and lots of them need a detailed instruction how to test the differences.)

Wouldn't it be better if extensions check the URL before they send it to redirect()?

I prefer to see Notices, Warnings, Errors while programming ;-) It helps to make my code better and find my bugs faster. I prefer a smaller Joomla core code than too many "if this variable is not correct please silently help, Joomla" ;-)
But: It was just a question. Just a private opinion. Nothing I have to decide here.

avatar fanno
fanno - comment - 14 Aug 2016

ya no problem, just thought i would bring it up as i founed it.

avatar brianteeman brianteeman - change - 25 Aug 2016
Status Information Required Pending
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Jan 2017

@fanno can you please tell, where to put "redirect("")" in?

avatar fanno
fanno - comment - 9 Jan 2017

I do not understand your question =( ?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Jan 2017

you wrote "redirect("") would do it" > in which file to write redirect("")?

avatar mbabker
mbabker - comment - 21 May 2017

Testing instructions:

Put a call to JFactory::getApplication()->redirect(''); anywhere. Based on the original report, pre patch this will emit a PHP notice and should not post-patch.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 May 2017

@mbabker "Anywhere" means for Example in configuration.php?

avatar bertmert
bertmert - comment - 22 May 2017

for Example in configuration.php

No, because framework must be initialized first. I think index.php of template is a "good" place.

There's a difference if you test (without patch) with
no argument
JFactory::getApplication()->redirect();
==> I get a Joomla error page ("Too few arguments to function JApplicationCms::redirect(), 0 passed...")
or empty string
JFactory::getApplication()->redirect('');
==> I get an "endless redirection error" from the browser.

Current staging. PHP 7.1. FF. Protostar. Error Reporting: System Default.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 May 2017

@bertmert looks like JFactory::getApplication()->redirect(); is on wrong Place (Test without PR).

index.php:

/**
 * @package    Joomla.Site
 *
 * @copyright  Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * Define the application's minimum supported PHP version as a constant so it can be referenced within the application.
 */
JFactory::getApplication()->redirect();
define('JOOMLA_MINIMUM_PHP', '5.3.10');

got in php_error.log:

PHP Fatal error:  Uncaught Error: Class 'JFactory' not found in /Applications/MAMP/htdocs/J3/index.php:12
Stack trace:
#0 {main}
  thrown in /Applications/MAMP/htdocs/J3/index.php on line 12

avatar bertmert
bertmert - comment - 22 May 2017

I think index.php of template is a "good" place.

Not in index.php in JoomlaRoot but template, e.g. protostar's index.php

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 May 2017

Protostar > index.php:

/**
 * @package     Joomla.Site
 * @subpackage  Templates.protostar
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
JFactory::getApplication()->redirect();
/** @var JDocumentHtml $this */

Frontend:

bildschirmfoto 2017-05-22 um 15 51 18

php_error.log:

Uninitialized string offset: 0 in /Applications/MAMP/htdocs/J3/libraries/joomla/application/web.php on line 520
avatar squ1773l squ1773l - test_item - 21 Aug 2017 - Tested unsuccessfully
avatar squ1773l
squ1773l - comment - 21 Aug 2017

I have tested this item ? unsuccessfully on 4106552

I installed a fresh copy from github. (Joomla! 3.8.0-beta3-dev)
If I try to apply the patch I got the following error:
"The file marked for modification does not exist: libraries/joomla/application/web.php"

In "/protostar.index.php" I tested:

"JFactory::getApplication()->redirect('');"
>> Redirecting to the root of the site. (e.g. http://localhost/)

"JFactory::getApplication()->redirect();"
>> Error: "Array to string conversion in C:\xampp\htdocs\wpw\templates\protostar\error.php on line 118 Array"

But I think redirecting to an empty url doesn't make sense.
So the error is justified.

@icampus


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11151.

avatar CiverBlack CiverBlack - test_item - 21 Aug 2017 - Tested unsuccessfully
avatar CiverBlack
CiverBlack - comment - 21 Aug 2017

I have tested this item ? unsuccessfully on 4106552

I have applied the patch and tested it for both cases JFactory::getApplication()->redirect(''); and JFactory::getApplication()->redirect(); in Firefox, Chrome and Safari. I put it into the protostar/index.php but in both cases i got the error exactly like when i disabled the patch.

@icampus


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11151.

avatar roland-d roland-d - test_item - 21 Aug 2017 - Tested unsuccessfully
avatar roland-d
roland-d - comment - 21 Aug 2017

I have tested this item ? unsuccessfully on 4106552

I have tested this as well and the fix works for half of the cases. First of all, this PR needs to be updated with the current codebase as the change needs to be in the new file located at libraries/src/Application/WebApplication.php on line 575.

Testing with JFactory::getApplication()->redirect(''); will throw the undefined notice and this patch fixes this as it no longer throws the notice.

Testing with JFactory::getApplication()->redirect(); throws another notice PHP Notice: Array to string conversion. This patch doesn't fix this. It will be good if this can be included in this fix as well.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11151.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 25 Aug 2018

If this Issue get no Response, it will be closed at 22th September 2018.

avatar franz-wohlkoenig franz-wohlkoenig - change - 23 Sep 2018
The description was changed
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-09-23 05:16:35
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2018
Status Closed Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2018
The description was changed
Status Pending Closed
Closed_Date 2018-09-23 05:16:35 2018-09-23 05:16:36
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - edited - 23 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 23 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - close - 23 Sep 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 23 Sep 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 23 Sep 2018

This has been closed due to lack of response to the requests above – it can always be reopened.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11151.

Add a Comment

Login with GitHub to post a comment