Post by keithb » Fri Feb 11, 2011 6:42 pm

Whilst debugging an admin change I was doing (on Windows locally) I found that VQMod was causing some of the files to be loaded twice (taking several milliseconds longer at least :) ) and on checking found it was due to the path strings being different before and after calling vqmod->modCheck and hence the comparison check between $file and $default failing when the files really were the same

I didn't want to change the code in the main program as it only happens when using VQMod so
I simply changed code in vqmod\vqmod_opencart.xml to stop it
(In a similar manner to the way that the modCheck function changed the path)

FIND

Code: Select all

		
<operation>
    <search position="before"><![CDATA[require($default);]]></search>
    <add>
<![CDATA[global $vqmod; $default = $vqmod->modCheck($default);]]></add>
</operation>

ADD AFTER

Code: Select all

<operation>
            <search position="replace"><![CDATA[$file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php';]]></search>
            <add><![CDATA[$file = str_replace("\\", "/", DIR_LANGUAGE . $this->directory . '/' . $filename . '.php');]]></add>
</operation>
I note Q that you say you have changed a lot of this for the next v1.0.9 it may no longer apply then

MY CAR BULBS


New member

Posts

Joined
Thu Jun 03, 2010 6:12 pm


Post by Qphoria » Fri Feb 11, 2011 9:00 pm

ocnewby wrote: It appears that in vQmod one needs to specify a specific occurrence of a shorter piece of code and then replace a block of text rather than positively identifying the actual code in the middle
Yes, 99% of the time you should be able to find some unique piece of code
The other 1% of the time you can use the index attribute to specify a particular one
My post actually had several related issues.
1. How to search for text using vQmod that spans multiple lines of code.
2. What is the difference when text is displayed in a long concatenated string or formatted/indented like a programmer editor. eg: basic windows notepad VS Notepad2
3. Am I changing the code text if I copy the long concatenated string into notepad 2, and then paste it back to notepad for re-upload to the server?
4. If I am changing the actual code text in statement 3., then would I be breaking my vQmod operation by doing that?
1. You have to use the method shown above with the offset.
2. vQmod trims the search string. Empty lines, spaces, cr, lf, etc is all stripped away.
3. You are over thinking it.. don't worry so much about lines and concatenation.
- Find a unique line as your search line
- if you need to use offset to replace a few lines then use it, but this is a fairly rare need
I've not run into any situation yet that I couldn't get around with the parameters available
4. You can change the actual code, but just be sure to remove it from the vQmod script so it doesn't double it.

Maybe a future revision of vQmod could specify a search that specified a start text, and an end text and that would more positively identify a section of code? Actually as I type this that sounds like a good way to bypass cr/lf issues.
Yes this is another idea, Though if you have a block like:

Code: Select all

public function test() {
    if ($x=$y) {
        echo 'something';
    }
}
It is hard to say the start line is: "public function test() {"
and the end line is "}" since there are many in that function.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Johnathan » Sat Feb 12, 2011 12:20 pm

Hey Q, this is only a pseduo-bug, but I'm not sure if you already know of this behavior: if you have a mod file that contains the same file reference more than once, it will apply all the mods to that file as many times as the file is referenced. For instance, if I'm organizing my mod like so:

Code: Select all

    <!-- Do Edit #1 -->
    <file name="admin/view/template/common/header.tpl">
        <operation>
            ...operation #1...
        </operation>
    </file>
    
    <!-- Do Edit #2 -->
    <file name="admin/controller/common/home.php">
        <operation>
            ...operation #2...
        </operation>
    </file>
    <file name="admin/view/template/common/header.tpl">
        <operation>
            ...operation #3...
        </operation>
    </file>
 
It will do operation #1 twice and operation #3 twice. Obviously, this can be easily solved by putting all of the file operations in a single file reference, but it would be nice to have flexibility like this.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Qphoria » Sat Feb 12, 2011 9:54 pm

When you say "twice" you mean the same code gets added 2 times? I know there is an issue with reprocessing the file a couple times but i've never seen it duplicate any code... but that may be because I've used replace in those cases. I'll take a look into this. thanks

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Johnathan » Sat Feb 12, 2011 10:57 pm

Yeah, if you used a "replace" it wouldn't have found it the second time, but I did it using "after" and it added the new line twice. I tested it earlier and even just having a second blank file reference later on will duplicate any of the operations before it.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by fido-x » Sun Feb 13, 2011 1:16 am

Johnathan, no offence intended, but since you didn't mention it. Did you try using index="1" in the search part of your operation? Sort of like this:

Code: Select all

<!-- Do Edit #1 -->
<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="replace" index="1"><![CDATA[
        ...search #1
        ]]></search>
        <add><![CDATA[
        ...replace #1
        ]]></add>
    </operation>
</file>

<!-- Do Edit #2 -->
<file name="admin/controller/common/home.php">
    <operation>
        <search position="replace" index="1"><![CDATA[
        ...search #2
        ]]></search>
        <add><![CDATA[
        ...replace #2
        ]]></add>
    </operation>
</file>

<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="replace" index="1"><![CDATA[
        ...search #3
        ]]></search>
        <add><![CDATA[
        ...replace #3
        ]]></add>
    </operation>
</file> 

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by JAY6390 » Sun Feb 13, 2011 1:19 am

That would work for replaces, but with the "after" surely it would still have the same problem

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by fido-x » Sun Feb 13, 2011 1:34 am

Maybe something like this:

Code: Select all

<!-- Do Edit #1 -->
<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="after" index="1"><![CDATA[
        ...search #1
        ]]></search>
        <add><![CDATA[
        ...insert #1
        ]]></add>
    </operation>
</file>

<!-- Do Edit #2 -->
<file name="admin/controller/common/home.php">
    <operation>
        <search position="after" index="1"><![CDATA[
        ...search #2
        ]]></search>
        <add><![CDATA[
        ...insert #2
        ]]></add>
    </operation>
</file>

<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="after" index="2"><![CDATA[
        ...search #3
        ]]></search>
        <add><![CDATA[
        ...insert #3
        ]]></add>
    </operation>
</file> 
By changing the index to "2" in the second operation on "admin/view/template/common/header.tpl ", the insert should go in after the second occurrence of the search parameter.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Xsecrets » Sun Feb 13, 2011 1:48 am

maybe just add to the instructions that you should only have one file tag per file within the same mod. I really don't see why you would want multiple file tags for the same file anyways. You can do multiple operations within the same tag.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Sun Feb 13, 2011 1:54 am

I think it is rare to do 2 separate <file> tags with the same file and that is why we haven't seen too many issues with this, but it should still be addressed. I know in my vqmod.log I see it do the replace in the system/library/language.php file and then later it tries again but fails with "search not found" because it was already replaced. If it was anything besides replace it could be an issue

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Sun Feb 13, 2011 1:54 am

Xsecrets wrote:maybe just add to the instructions that you should only have one file tag per file within the same mod. I really don't see why you would want multiple file tags for the same file anyways. You can do multiple operations within the same tag.
Exactly!

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by JAY6390 » Sun Feb 13, 2011 1:58 am

Surely merging all of the XML operations into one if they have the same file name should be pretty straight forward since they're all loaded before execution

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by openmycart.com » Sun Feb 13, 2011 5:00 am

JAY6390 wrote:That would work for replaces, but with the "after" surely it would still have the same problem
for me also found not work for "before"
e.g.

Code: Select all

    <!-- Do Edit #1 -->
    <file name="admin/view/template/common/header.tpl">
        <operation>
            <search position="before" index="1,2,5,6,9"><![CDATA[
            ...search #1
            ]]></search>
            <add><![CDATA[
            ...insert #1
            ]]></add>
        </operation>
    </file>
but it will work if i declare it one by one e.g. index="1", index="2", etc...

My another issue:
I tried in my client's hosting, it won't work, the cache temporary file didn't create,all .xml files sample included but also won't work, when i open the vqcache folder, i Found only
vqcache_system_engine_controller.php
vqcache_system_engine_front.php
vqcache_system_engine_loader.php
vqcache_system_library_language.php
vqcache_system_startup.php

Find and get many various of opencart modules, themes, mods, etc for your opencart store at http://www.openmycart.com/oc/, OPENCART SITE customization and Maintenance supports at here


User avatar
Active Member

Posts

Joined
Tue Oct 12, 2010 4:47 am


Post by Qphoria » Sun Feb 13, 2011 8:39 am

openmycart.com wrote: My another issue:
I tried in my client's hosting, it won't work, the cache temporary file didn't create,all .xml files sample included but also won't work, when i open the vqcache folder, i Found only
vqcache_system_engine_controller.php
vqcache_system_engine_front.php
vqcache_system_engine_loader.php
vqcache_system_library_language.php
vqcache_system_startup.php
This can happen for a number of reasons:
- You are not loading the page that uses the xml. Like if you have a mod for the product page, the file wont change on the homepage
- The file may not exist due to a typo in the xml file. This will show up in the log
- The operation could not be completed so it reverted back to the original file
- The operation may appear to not be working if the xml file has a change for the "default" theme but store uses a different theme. I am working on trying to get wildcards to work for things like that in the next version

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by openmycart.com » Sun Feb 13, 2011 10:03 am

Actually it work when in localhost with xampp
Qphoria wrote: This can happen for a number of reasons:
- You are not loading the page that uses the xml. Like if you have a mod for the product page, the file wont change on the homepage
page loaded
Qphoria wrote: - The file may not exist due to a typo in the xml file. This will show up in the log
OK, in log file

2011-02-12 19:57:15.5307070 - LIST OF SOURCE FILES TO MODIFY:
2011-02-12 19:57:15.5307140 - /home/xxxx/public_html/admin/controller/catalog/product.php
2011-02-12 19:57:15.5307210 - /home/xxxx/public_html/admin/language/english/catalog/product.php
2011-02-12 19:57:15.5307280 - /home/xxxx/public_html/admin/model/catalog/product.php
2011-02-12 19:57:15.5307350 - /home/xxxx/public_html/admin/view/template/catalog/product_list.tpl
2011-02-12 19:57:15.5307420 - /home/xxxx/public_html/catalog/controller/product/search.php
2011-02-12 19:57:15.5307490 - /home/xxxx/public_html/catalog/view/theme/default/template/product/search.tpl
2011-02-12 19:57:15.5307570 - /home/xxxx/public_html/system/startup.php
2011-02-12 19:57:15.5307640 - /home/xxxx/public_html/system/engine/controller.php
2011-02-12 19:57:15.5307710 - /home/xxxx/public_html/system/engine/front.php
2011-02-12 19:57:15.5307780 - /home/xxxx/public_html/system/engine/loader.php
2011-02-12 19:57:15.5307850 - /home/xxxx/public_html/system/library/language.php
2011-02-12 19:57:15.5307920 - LIST OF NON-EXISTANT SOURCE FILES REFERENCED IN THE SCRIPTS:
2011-02-12 19:57:15.5307990 - /home/xxxx/public_html/admin/controller/catalog/product.php
2011-02-12 19:57:15.5308060 - /home/xxxx/public_html/admin/language/english/catalog/product.php
2011-02-12 19:57:15.5308130 - /home/xxxx/public_html/admin/model/catalog/product.php
2011-02-12 19:57:15.5308200 - /home/xxxx/public_html/admin/view/template/catalog/product_list.tpl
2011-02-12 19:57:15.5308270 - BEGIN MODS...
2011-02-12 19:57:15.5309990 - -----------------------------------------------------

from the log file it look like the files unlisted because the admin folder read as "admin" instead of e.g. "admin123" but from it the vqmod.php read .xml file correctly, CMIIW
Qphoria wrote: - The operation could not be completed so it reverted back to the original file
if operation could not completed i think the warning/error message would be out, right? CMIIW
Qphoria wrote: - The operation may appear to not be working if the xml file has a change for the "default" theme but store uses a different theme. I am working on trying to get wildcards to work for things like that in the next version
NO change, it worked on admin page with all default theme and files

Find and get many various of opencart modules, themes, mods, etc for your opencart store at http://www.openmycart.com/oc/, OPENCART SITE customization and Maintenance supports at here


User avatar
Active Member

Posts

Joined
Tue Oct 12, 2010 4:47 am


Post by Qphoria » Sun Feb 13, 2011 2:04 pm

openmycart.com wrote: 2011-02-12 19:57:15.5307920 - LIST OF NON-EXISTANT SOURCE FILES REFERENCED IN THE SCRIPTS:
2011-02-12 19:57:15.5307990 - /home/xxxx/public_html/admin/controller/catalog/product.php
2011-02-12 19:57:15.5308060 - /home/xxxx/public_html/admin/language/english/catalog/product.php
2011-02-12 19:57:15.5308130 - /home/xxxx/public_html/admin/model/catalog/product.php
2011-02-12 19:57:15.5308200 - /home/xxxx/public_html/admin/view/template/catalog/product_list.tpl
2011-02-12 19:57:15.5308270 - BEGIN MODS...
2011-02-12 19:57:15.5309990 - -----------------------------------------------------

from the log file it look like the files unlisted because the admin folder read as "admin" instead of e.g. "admin123" but from it the vqmod.php read .xml file correctly, CMIIW
Well this seems to be it right here. If you've renamed your admin folder to admin123 then it won't find it. You need to update the xml file to look for admin123

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by openmycart.com » Sun Feb 13, 2011 7:18 pm

Qphoria wrote: Well this seems to be it right here. If you've renamed your admin folder to admin123 then it won't find it. You need to update the xml file to look for admin123
Actually I did it, just want to show up the issues, and hopefully next version vqmod able to auto read the admin folder, language, theme, any idea?

Regards,

Find and get many various of opencart modules, themes, mods, etc for your opencart store at http://www.openmycart.com/oc/, OPENCART SITE customization and Maintenance supports at here


User avatar
Active Member

Posts

Joined
Tue Oct 12, 2010 4:47 am


Post by JAY6390 » Sun Feb 13, 2011 7:21 pm

vQmod is not actually just made for OC, it's made to cover pretty much any system You could use it with wordpress, drupal, joomla etc. In fairness having to change a couple of folder names in an XML file's hardly going to hurt anyone, especially when you consider just how much people would have to hack their files together without it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Johnathan » Sun Feb 13, 2011 10:56 pm

fido-x wrote:Maybe something like this:

Code: Select all

<!-- Do Edit #1 -->
<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="after" index="1"><![CDATA[
        ...search #1
        ]]></search>
        <add><![CDATA[
        ...insert #1
        ]]></add>
    </operation>
</file>

<!-- Do Edit #2 -->
<file name="admin/controller/common/home.php">
    <operation>
        <search position="after" index="1"><![CDATA[
        ...search #2
        ]]></search>
        <add><![CDATA[
        ...insert #2
        ]]></add>
    </operation>
</file>

<file name="admin/view/template/common/header.tpl">
    <operation>
        <search position="after" index="2"><![CDATA[
        ...search #3
        ]]></search>
        <add><![CDATA[
        ...insert #3
        ]]></add>
    </operation>
</file> 
By changing the index to "2" in the second operation on "admin/view/template/common/header.tpl ", the insert should go in after the second occurrence of the search parameter.
Thanks for the suggestion, but unfortunately that won't work. There's only one index of the first search line; simply having the second file reference duplicates the first operation. It reads the first operation (i.e. <search position="after" index="1">) and does it twice.

I tried to look up what's happening in the log, but my log only writes out what vqmod_opencart.xml does, and then ends. Does anyone else have this problem? This is on a local installation.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Xsecrets » Sun Feb 13, 2011 11:41 pm

why not just do

Code: Select all

    <!-- Do Edit #1 -->
    <file name="admin/view/template/common/header.tpl">
        <operation>
            <search position="after" index="1"><![CDATA[
            ...search #1
            ]]></search>
            <add><![CDATA[
            ...insert #1
            ]]></add>
        </operation>
        <operation>
            <search position="after" index="2"><![CDATA[
            ...search #3
            ]]></search>
            <add><![CDATA[
            ...insert #3
            ]]></add>
        </operation>
    </file>

    <!-- Do Edit #2 -->
    <file name="admin/controller/common/home.php">
        <operation>
            <search position="after" index="1"><![CDATA[
            ...search #2
            ]]></search>
            <add><![CDATA[
            ...insert #2
            ]]></add>
        </operation>
    </file> 

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US
Who is online

Users browsing this forum: No registered users and 13 guests