Installing mods: search does not find (a == b)

Started by kuklovod, December 07, 2005, 03:39:54 AM

Previous topic - Next topic

kuklovod

Ok, so I wasted like 4 hours on this problem: somehow search function is not able to find ==, in context "if (a == b) {}". No matter what I try - reverse=true or uninstall.xml, it just fails. Replace (a == b) with (a==b), works fine. It's not tabs or anything, two simple space characters.

Is this a known problem, should not it be documented? Really frustrating to spend time on silly things like that :)

Dannii

I've never had any problems like this. Can you please explain more precisely what you were searching for?
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

kuklovod

#2
ok i made a mod that had this operation among others:


<operation>
<search position="replace"><![CDATA[
</td></tr>';
]]></search>
<add><![CDATA[
</td></tr>';
if ($context['is_sticky'] && ($message['id'] == $context['topic_first_message'])) {
echo '<tr><td class="titlebg" style="padding: 3px 0px;"></td></tr>';
}
]]></add>
</operation>


It was installing but reverse (uninstall) failed because it was not able to find "$message['id'] == $context['topic_first_message']", modifying it to "$message['id']==$context['topic_first_message']" fixed the problem. single = worked as well...

Replace instead of before there is simply because I was trying to find the reason for that failure, it didn't work with "before" as well. It is a search problem, most definitely.

Dannii

What else is happening? You'll need a better search key than just </td></tr>'; The search part has to be unique.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

kuklovod

#4
nothing else. this string is unique for the file it's being searched in. again, it is a reduced version of the search pattern i used originally, because I was trying to narrow down the problem. if you try this operation on Themes/<theme>/Display.template.php and then will try to reverse it, you will get a failure. if you replace " == " with "==", it will pass.

Dannii

If you're sure that string is unique, and if that's the only operation then I can't see why it wouldn't work.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

kuklovod

#6
No, there are other operations, but they are in different files/places, and they are all successfull. This operation alone was causing all the trouble, and I narrowed it down to the exact cause - " == " not being found.

Stranger yet - I can't reproduce it with simple (a == b) cases, but the original fails every time - so it's a combination of things :( This code can't be uninstalled, so you can test it:

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">

<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>bug with search</id>
<version>1.0</version>

<file name="$themedir/Display.template.php">
   <operation>
   <search position="replace"><![CDATA[
   </td></tr>';
   ]]></search>
   <add><![CDATA[
   </td></tr>';
   if ($context['is_sticky'] && ($message['id'] == $context['topic_first_message'])) {
      // anything
   }
   ]]></add>
   </operation>
</file>
</modification>

Advertisement: