ANUBHAV67 / vqmod

Automatically exported from code.google.com/p/vqmod
0 stars 0 forks source link

Replace blocks of code #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
NOTE THAT THIS IS FOR VQMOD ENGINE ERRORS ONLY. FOR GENERAL ERRORS FROM
MODIFICATIONS CONTACT YOUR DEVELOPER

What steps will reproduce the problem?
1.
Opencart : catalog/controller/checkout/cart.php (or other files that control 
breadcrumbs)
2. Code in files - basically there are multiple lines that add items to the 
breadcrumbs array (data['breadcrumbs'][] = new item value)

$this->data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/home'),
            'text'      => $this->language->get('text_home'),
            'separator' => false
        ); 

        $this->data['breadcrumbs'][] = array(
            'href'      => $this->url->link('checkout/cart'),
            'text'      => $this->language->get('heading_title'),
            'separator' => $this->language->get('text_separator')
        );

3. vQmod script:

<search position="replace">
<![CDATA[$this->data['breadcrumbs'][] = array(
'href'      => $this->url->link('common/home'),
'text'      => $this->language->get('text_home'),
'separator' => false
);]]>
</search>

<add><![CDATA[
]]></add>

What is the expected output? What do you see instead?
the expected output is that the entire code block should be replaced, so that 
the "home" breadcrumb will not be generated.

What I see instead:
Nothing, just an error in the log. Apparently, vQmod cannot handle replacement 
of code blocks.

I believe that this feature is a "must have", since there are a lot of 
scenarios in which we need to replace a code block, but the php file in 
question has a lot of similar code blocks.

vQmod Version: 2.4.1
Server Operating System:centOS

Please provide any additional information below.

More clear example:
<?php
if ($a == 4){
   $index[] = $a;
   echo 'a is '.$a;
}
if ($a == 5){
   $index[] = $a;
   echo 'a is '.$a;
   echo 'a is not 4';
}
if ($a == 6){
   $index[] = $a;
   echo 'a is '.$a;
   echo 'a is not 4 and a is not 5';
}
?>

What if I would want to replace the first block of code:
if ($a == 4){
   $index[] = $a;
   echo 'a is '.$a;
}
with something else?
Notice that this is formatted php code, not on a single line.
The code above is just some example code to illustrate what I mean.

Original issue reported on code.google.com by DariusMi...@gmail.com on 6 Aug 2013 at 7:55

GoogleCodeExporter commented 9 years ago
vQmod is a SINGLE LINE replacement tool. See the examples on the scripting page 
in the wiki

Original comment by DJG6...@gmail.com on 6 Aug 2013 at 7:56

GoogleCodeExporter commented 9 years ago
I found out that currently vQmod is a SINGLE LINE replacement tool, you don't 
have to yell (caps lock).
What I'm saying is that this would be a really nice feature to be implemented 
in vQmod.

P.S Just to make it clear for everyone that reads this, what I mean by:
the expected output is that the entire code block should be replaced, so that 
the "home" breadcrumb will not be generated.
is that the first code block should be replaced, the one that generates the 
"home" breadcrumb.

Original comment by DariusMi...@gmail.com on 6 Aug 2013 at 7:59

GoogleCodeExporter commented 9 years ago
It's been requested before - there are no plans for it to be added. There are 
ways of doing this, such as the offset. And while it wasn't necessarily 
shouting, it appears you can't read the quite clear text at the top of this 
page - "NOTE THAT THIS IS FOR VQMOD ENGINE ERRORS ONLY"

Original comment by DJG6...@gmail.com on 6 Aug 2013 at 8:02

GoogleCodeExporter commented 9 years ago
I think that this issue is related to the vQmod engine, isn't the engine the 
one that handles vQmod operations?
I know that what I'm looking for can probably be done using "offset", but over 
here
https://code.google.com/p/vqmod/wiki/Examples?#'Multi-line_Replace'_Example
you advise not to use this feature.

Original comment by DariusMi...@gmail.com on 6 Aug 2013 at 8:09

GoogleCodeExporter commented 9 years ago
It's for errors, not "things you want", operations or not. It doesn't fire 
rainbows out of a unicorns ass either, and that's not been in an error report 
just yet

Original comment by DJG6...@gmail.com on 6 Aug 2013 at 8:16

GoogleCodeExporter commented 9 years ago
Are you having a bad day?
From my (the user) point of view, this was an issue because there is no 
documentation whatsoever on how to use the index tag or the regex tag, so I 
just pasted my block of code in there and expected it to work as advertised.
Just because you don't charge money for your product, doesn't mean you get to 
speak crap to people that come here and report what they think it's an issue.
After all, the error log reported an error, that it could not find the search 
text even if it was there in the file:

File Name    : catalog/controller/product/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): 
$this->data['breadcrumbs'][] = array(
'href'      => $this->url->link('common/home'),
'text'      => $this->language->get('text_home'),
'separator' => false
);

As you can see, it says "search not found" even though the code is inside the 
file in question.
It could say "Hey, I can't replace multiple lines, see my documentation", and 
then I would have understood and I would have not loaded this page in my 
browser to report what appeared to be an issue.

Original comment by DariusMi...@gmail.com on 6 Aug 2013 at 8:21

GoogleCodeExporter commented 9 years ago
My day's been perfect... thanks for your concern

As for "no documentation whatsoever" - That's incorrect
https://code.google.com/p/vqmod/wiki/Scripting
Granted, it may not be an essay on how it works exactly, but it's made pretty 
clear that it's a single line search by the red text that states "Can only 
search single lines" and also tells you about multi line replacement: "if the 
search position is replace and offset 3 it will remove the code from the search 
line and the next 3 lines and replace it with the add data"

As for the error, while it may not be what you want it to say, it certainly 
isn't incorrect. Being a single line search system, it's accurate in that it 
didn't find your search on any single line

Regardless of what you may think on my tone towards yourself, the fact still 
remains that this is not a bug or engine error. Unless you have a valid reason 
to suggest otherwise, this conversation is done

Original comment by DJG6...@gmail.com on 6 Aug 2013 at 10:30