Edit report at http://bugs.php.net/bug.php?id=52198&edit=1

 ID:               52198
 Updated by:       paj...@php.net
 Reported by:      christian dot gnoth at arcor dot de
 Summary:          strpos not working correctly
 Status:           Bogus
 Type:             Bug
 Package:          Strings related
 Operating System: Linux
 PHP Version:      5.2.13

 New Comment:

Ok.



Using:



$post_lnk_string =
'href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"';

$strpos_ret = strpos($post_lnk_string, 'article&id=');

var_dump($strpos_ret);



This script is exactly what you are doing. The output is:



int(40)



It works.



Your analyze about the memory are is wrong. Please check the
implementation if you like to verify it by yourself.


Previous Comments:
------------------------------------------------------------------------
[2010-07-04 22:40:03] christian dot gnoth at arcor dot de

Hello,

thank you for your qualified answer. But, please take a look at the
following lines:



$strpos_ret = strpos( $post_lnk_string, 'article&id=');

echo 'Post ID: ' . $j2wp_post['ID'] . ' link: ' . $post_lnk_string . '
:' . $strpos_ret . ':<br />'; 



and here is the output:



Post ID: 107 link:
href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"
::



So the strpos function has no idea from were the input is comming.
Infact it is for the problem not intresting. Question is, from which
memory area it gets the input and what is there and how it is moved to
the strpos function. 

The variable which is passed to strpos contains the string
'article&id=', but this string is not found by the strpos function. 



So it is a bug in the PHP interpreter!!!



As you are the developer you should see that!!!

------------------------------------------------------------------------
[2010-07-04 21:42:50] paj...@php.net

Please understand that strpos has absolutely no idea where the strings
you pass it come from (ich meine es: echt keine Ahnung).



What is so hard to understand to actually do what Rasmus has been asking
for a week now? Provide a script like the one I wrote in my previous
comment.



If you can't reproduce it using such a simple script, then something is
wrong somewhere else in your code.



If you keep need support, I would suggest to go to either the
php-general mailing or to whatever is the support channel for Wordpress.
But bugs.php.net is not such channel.



Thanks for your understanding.

------------------------------------------------------------------------
[2010-07-04 21:36:37] christian dot gnoth at arcor dot de

to reproduce this case is not simple, the script is part of a wordpress
plugin and runs within the wordpress environment with mysql access. It
is a Joomla to Wordpress Migrator. It reads the Joomla tables and
inserts the entries in the wordpress posts table. After that the URL's
within the posts can be changed and pointed to the new wordpress posts.



I have provided the source code and the mysql table structure under:



http://files.it-gnoth.de/download/php_report/



To have the same environment for this case you have to do the following
steps:



- install wordpress (I have the multisite feature enabled)

- import the sql file I proved into the mysql database - it contains the
joomla content entries

- install the plugin in wordpress

- fill up the mysql connection parameters in the plugin admin panel

- start the migration of the joomla content to wordpress

- start the url change proccess

------------------------------------------------------------------------
[2010-07-04 20:09:23] ras...@php.net

We don't want you to give us a case where it doesn't happen.  We want
you to come 

up with a simpler version of your code where the problem *does* happen. 
And we 

have looked at the source code you have provided and there is nothing
visually 

wrong with it.  Without an actual reproducing case, there is nothing we
can do, 

and you still have not provided that.

------------------------------------------------------------------------
[2010-07-04 19:46:59] christian dot gnoth at arcor dot de

Hello,

I can not follow you how you come to the idea not to analyze the given
source code of a bug report, simply because you do not want use your
mind to understand the logic of the source code.



For this report I made the echos in the source code that you can see the
content of the variable passed to the strpos function.



As I wrote many times, I do not doubt that the strpos function is
working in a different case and as I wrote it is working in different
places in my sourcecode. BUT !!!! As you can see strpos is not able to
find:



'article&id='

in

href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"



in the cylcle of many nested function calls.



So - it is not a question of "strpos is working or not", but as I think
a question of memory areas which may be not correct filled, passed,
handled.....



And for that problem it is of no use to create other circumstances where
this problem is not happening.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52198


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52198&edit=1

Reply via email to