Community Forums

[MOD] - VirtualQMod "vQmod" Virtual File Modification System

Community created contributions & mods for OpenCart 1.x

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Thu Aug 25, 2011 1:20 pm

madimar wrote:
Qphoria wrote:Yes it is true, inline after/before would be good. But it can be done in a pseudo-way like I showed above.. by using replace and finding the line and replacing the same line with code after it. Since if that line changed anyway, it wouldn't match anyway so the same effect still happens.


I'm not sure I understood correctly. If you replace the line, you will have a different code in your file.
Adding directly in the file those str_replace operations (as in my example), mantains the original line unchanged in the file.
If all the other mods work in the same way, I think the conflict risk is minor even if not completely avoided.


Well no.. Think about it
You have to search "abc123"
and replace with "abc123-XYZ"

You are replacing the exact same code with the original code plus your new code.
And you are actually bound to rule since your search would have to match in the first place
So another script could use that same search tag without breaking anything

So If you had search "abc123"
and inline-after "-XYZ"
still resulting in "abc123-XYZ"
You'd still end up with all the same pieces of the puzzle
And another script could still search on the tag the same way.

It is 6 vs half-dozen.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18209
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby drivenbyweb » Thu Aug 25, 2011 1:50 pm

My log file has a bunch of lines in it that say ---DELAYED WRITE---. Searched google and the forum but can seem to find what it means. Does anyone know?
drivenbyweb
 
Posts: 12
Joined: Sun Jul 24, 2011 7:25 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Thu Aug 25, 2011 2:17 pm

drivenbyweb wrote:My log file has a bunch of lines in it that say ---DELAYED WRITE---. Searched google and the forum but can seem to find what it means. Does anyone know?

That was a feature I added to avoid write locking. It means the vqcache file couldn't be written to in a timely manner and took up to 1 sec to be written. It typically means your host is slow. But does it still work?
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18209
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby madimar » Thu Aug 25, 2011 3:50 pm

Qphoria wrote:
madimar wrote:
Qphoria wrote:Yes it is true, inline after/before would be good. But it can be done in a pseudo-way like I showed above.. by using replace and finding the line and replacing the same line with code after it. Since if that line changed anyway, it wouldn't match anyway so the same effect still happens.


I'm not sure I understood correctly. If you replace the line, you will have a different code in your file.
Adding directly in the file those str_replace operations (as in my example), mantains the original line unchanged in the file.
If all the other mods work in the same way, I think the conflict risk is minor even if not completely avoided.


Well no.. Think about it
You have to search "abc123"
and replace with "abc123-XYZ"

You are replacing the exact same code with the original code plus your new code.
And you are actually bound to rule since your search would have to match in the first place
So another script could use that same search tag without breaking anything

So If you had search "abc123"
and inline-after "-XYZ"
still resulting in "abc123-XYZ"
You'd still end up with all the same pieces of the puzzle
And another script could still search on the tag the same way.

It is 6 vs half-dozen.


Hmm, you convinced me... inline-after and replace (properly used) are equivalent.
What about my "experiment" of "str_replace or string concatenation - after" ? In this way, mainly for modified sql queries, if another mod applies a "not restricted" vqmod replace on the original text, maybe things can work without conflicts. Example

A) "standard vqmod"
1) First mod:
code:
Code: Select all
$sql = "abc123-XYZ";

vqmod search: 123 - replace 123-ABCD
result:
Code: Select all
$sql = "abc123-ABCD-XYZ";


2) Second mod:
code:
Code: Select all
$sql = "abc123-ABCD-XYZ";

(but supposed to be $sql = "abc123-XYZ";)
vqmod search: 123-XYZ - replace 123-XYZ-9999
result:
not match!

B) "madimar trick with str-replace"
1) First mod:
code:
Code: Select all
$sql = "abc123-XYZ";

vqmod search: $sql = "abc123-XYZ"; - after $sql = str-replace('123','123-ABCD' ,$sql);
result:
Code: Select all
$sql = "abc123-XYZ";
$sql = str-replace('123','123-ABCD' ,$sql);

equivalent to:
$sql = "abc123-ABCD-XYZ";

2) Second mod:
code:
Code: Select all
$sql = "abc123-XYZ";
$sql = str-replace('123','123-ABCD' ,$sql);

(but supposed to be $sql = "abc123-XYZ";)
vqmod search: 123-XYZ - replace 123-XYZ-9999
result:
Code: Select all
$sql = "abc123-XYZ-9999";
$sql = str-replace('123','123-ABCD' ,$sql);

equivalent to:
$sql = "abc123-ABCD-XYZ-9999";

Hmm... let me say, the modification conflict is avoided, even if the risk of mulfunction is still high, but maybe you are lucky and things work...

Any opinion about it?
User avatar
madimar
 
Posts: 994
Joined: Thu Sep 24, 2009 10:27 am

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Thu Aug 25, 2011 3:57 pm

Personally I try to have as little effect on the original code as I possibly can but sometimes it's inevitable that you are going to make changes that have the potential to screw up another mod/a mod will screw up your matches
In these situations, you just have to leave it be. You can't be held responsible for your mod not working with every other mod out there (take PC applications for example, they conflict on occasion - it just happens)
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby madimar » Thu Aug 25, 2011 4:03 pm

JAY6390 wrote:Personally I try to have as little effect on the original code as I possibly can but sometimes it's inevitable that you are going to make changes that have the potential to screw up another mod/a mod will screw up your matches
In these situations, you just have to leave it be. You can't be held responsible for your mod not working with every other mod out there (take PC applications for example, they conflict on occasion - it just happens)


Jay, you are perfectly right... but I'm incidentally personally work on some (3-4) indipendent vqmod mods. In same cases, with "standard" coding my mods conflict each other... :crazy:
So I tried to code these mods in order to not conflicting each other and the only way I currently found was that "complicate" one I was showing you...

Ok, you can't avoid conflict with the world of mods out there... but at least your own mods should be compatible!!! This is my situation!
User avatar
madimar
 
Posts: 994
Joined: Thu Sep 24, 2009 10:27 am

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Thu Aug 25, 2011 4:07 pm

If your mods can't use the same code, then clearly there's a better way of doing what you are doing. It's hard to give an example without seeing the code, but there's always a way around conflicts
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Thu Aug 25, 2011 4:10 pm

Actually what you're suggesting you could in fact use the regex method to figure out I guess. regular expressions are flexible if you do them right, so you shouldn't have a problem using that
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Thu Aug 25, 2011 4:26 pm

I think I see what you mean madimar,
But I think what Jay says kinda negates it...

It looks like your example is 2 mods that want to edit the same exact line in the same exact way, yeilding different results. But then the mods will have logical conflicts anyway.

if mod 1 says:
search: blue
replace: red

and mod 2 says
search: blue
replace: green

even if you tried some passive
str_replace(blue, red, $line)
str_replace(blue, gree, $line)

The end result is that those 2 mods do diff things to the same line are not compatible anyway.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18209
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby madimar » Thu Aug 25, 2011 5:39 pm

Qphoria wrote:I think I see what you mean madimar,
But I think what Jay says kinda negates it...

It looks like your example is 2 mods that want to edit the same exact line in the same exact way, yeilding different results. But then the mods will have logical conflicts anyway.

if mod 1 says:
search: blue
replace: red

and mod 2 says
search: blue
replace: green

even if you tried some passive
str_replace(blue, red, $line)
str_replace(blue, gree, $line)

The end result is that those 2 mods do diff things to the same line are not compatible anyway.


hmm... ;-) hope not annoying... if yes, please tell me... I will stop! Actually I'm saying :
str_replace(blue, blue red, $line)
str_replace(blue, blue green, $line)
result: blue green red

My typical case is in some mysql query, where I could typically need to add some fields to be select.

See please me original example (slightly modified):

Code: Select all
<operation>
            <search position="after"><![CDATA[
      $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
         ]]></search>
            <add><![CDATA[
      // madimar mod   
      $sql = str_replace (' FROM `', ', sr.name AS sales_rep FROM `', $sql);
      // madimar mod end     
         ]]></add>
        </operation>


Other mod:
Code: Select all
<operation>
            <search position="after"><![CDATA[
      $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
         ]]></search>
            <add><![CDATA[
      // madimar mod   
      $sql = str_replace (' FROM `', ', newfield AS newfield FROM `', $sql);
      // madimar mod end     
         ]]></add>
        </operation>


Final result is equivalent to:

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified, sr.name AS sales_rep, newfield AS newfield FROM `" . DB_PREFIX . "order` o";

.... for my own mods maybe I could do the same also with vqmod replace... :drunk: but a 3rd pty mod could try to search for that entire original line without matching it. :drunk: :drunk: :drunk:
User avatar
madimar
 
Posts: 994
Joined: Thu Sep 24, 2009 10:27 am

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Thu Aug 25, 2011 5:47 pm

The point is however that you shouldn't be searching for the entire line, and that's also why I suggested regex integration earlier on in the development. You could probably find a string a lot smaller than that that's still unique to that file, and add both in. This is why indexes are used too, so you can generalise the search, and home in on the right one using the index value
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby drivenbyweb » Thu Aug 25, 2011 5:52 pm

Qphoria wrote:
drivenbyweb wrote:My log file has a bunch of lines in it that say ---DELAYED WRITE---. Searched google and the forum but can seem to find what it means. Does anyone know?

That was a feature I added to avoid write locking. It means the vqcache file couldn't be written to in a timely manner and took up to 1 sec to be written. It typically means your host is slow. But does it still work?


It works great. I'm working locally as the only user and this machine is plenty fast enough. Is there anything in the formatting of the XML files that causes this to happen or is it just PHP and the OS?
drivenbyweb
 
Posts: 12
Joined: Sun Jul 24, 2011 7:25 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Thu Aug 25, 2011 5:56 pm

This also happens as a result of ajax calls running while your script is still running, and can cause an issue
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby affect » Fri Aug 26, 2011 2:08 pm

Trying to install latest vQmod via autoinstaller per opencart_install.txt.

All I'm getting is the "VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!" every time I run the installer, nothing more. Nothing in server error logs, no new files in vqmod folder, nothing in vqcache either. Example mods don't seem to work, at least I'm not getting anything at all neither by using helloworld example nor other xml files from examples folder.

Tried both 775 and 777 to vqmod and vqcache, also tried both recursively.

Can't read 32 pages of discussion here at the moment, what could be the problem?
Our OpenCart Extensions: Product Maps, Price Match Lite, Option Downloads, Question & Answer, Google Maps & more in the store!

Join our unofficial IRC support channel #opencart @ irc.freenode.net for help.

Contact us for cool icons, custom extensions, template slicing & everything else!
User avatar
affect
 
Posts: 150
Joined: Sat Aug 13, 2011 9:04 am

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Fri Aug 26, 2011 2:14 pm

Have you checked the index.php files to see if they have been overwritten? Just look for vQmod in the first 20 lines of the file. If its not there, then the problem lies with their permissions. Try setting them to 644 while you install it
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby affect » Fri Aug 26, 2011 2:43 pm

Actually it looks like the problem was in permissions indeed, but not in vqmod's permissions rather than in index.php which wasn't writable. Somehow I haven't thought about it from the beginning. Would be nice if there was a line about it in the opencart_install.txt.

UPD:
Just noticed admin/index.php needs to be writable too and since it wasn't it didn't get changed. Actually it would be cool if there was an is_writable check or something and an error message about permissions in the installer.
Our OpenCart Extensions: Product Maps, Price Match Lite, Option Downloads, Question & Answer, Google Maps & more in the store!

Join our unofficial IRC support channel #opencart @ irc.freenode.net for help.

Contact us for cool icons, custom extensions, template slicing & everything else!
User avatar
affect
 
Posts: 150
Joined: Sat Aug 13, 2011 9:04 am

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Fri Aug 26, 2011 2:47 pm

Yeah, there does need to be that added to it. For vQmod 2.0 it will be done
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Fri Aug 26, 2011 4:11 pm

Yea the installer doesn't check file permission on the index.php file. Jay. fix it!
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18209
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Fri Aug 26, 2011 4:18 pm

I'd rather not use expletives to reply to that comment, so I'll simply say "do one, guvna"
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4635
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Johnathan » Sat Aug 27, 2011 12:01 am

Qphoria wrote:Yea the installer doesn't check file permission on the index.php file. Jay. fix it!

JAY6390 wrote:I'd rather not use expletives to reply to that comment, so I'll simply say "do one, guvna"

You two sound like a (slightly odd) married couple. :laugh:
Image
ImageImageImageImageImageImageImageImageImage
User avatar
Johnathan
Global Moderator
 
Posts: 2866
Joined: Thu Dec 17, 2009 7:08 pm

PreviousNext

Return to Free Contributions

Who is online

Users browsing this forum: No registered users and 9 guests

Hosted by Arvixe Web Hosting