Vqmod xml script not working for opencart config.php - opencart

I am writing VQMod XML to edit config.php in opencart, i wrote below XML and saved it inside XML folder.
<modification>
<id>VQMOD CORE FOR OPENCART - DO NOT REMOVE</id>
<version>1.4.x and 1.5.x</version>
<vqmver>2.2.1</vqmver>
<author>Senthil</author>
<file name="./config.php">
<operation>
<search position="after"><![CDATA[
define('DB_PREFIX', 'op');
]]></search>
<add><![CDATA[
define('HTTP_IMAGE_2', 'http://localhost/opcart/image/');
define('HTTPS_IMAGE_2', 'http://localhost/opcart/image/');
define('DIR_IMAGE_2', '/Users/[username]/Sites/opcart/image/');
]]></add>
</operation>
</file>
But its not creating new cache file in vqcache folder as its doing for other files. No errors in log file. I have write permission to the vqcache folder and config file. Any help will be useful.

vQmod's do not work on those files. It works basically on all php/tpl files above the index.php folder (ie 1 or more files deeper)

Yes this is possible. You can use VQMod everywhere that a file is accessed, as long as there is a logical chain of "touch" to that file and no rogue requires. In this case, this is semi-untested beyond a dev instance, and there are "security" risks involved with making configs moddable.
To do it, you just need to edit index.php (and admin/index.php). Move the following to the top of of the index.php's (under define VERSION) so that it comes before the check for config.php's:
// VirtualQMOD
require_once('./vqmod/vqmod.php');
VQMod::bootup();
Then change the way OC is pulling config.php:
require_once('config.php');
By adding in the check for mods:
require_once(VQMod::modCheck('config.php'));
Access your catalog/admin so VQ can build, then check /vqmod/vqcache for file:
vq2-config.php
If it's there, and your changes are in, success.
PS: You can just use <file name="config.php"> in your XML file, no need for the relative ./.

Related

vQmod and OCmod duplicating modifications

I'm using vQmod 2.5.1 and Opencart 2.0.3.1, and I've run into an interesting problem.
I've got a vQmod xml that makes some modifications to the system/library/cart.php file. Here's an example:
<file name="system/library/cart.php">
<operation>
<search position="after"><![CDATA[private $data]]></search>
<add><![CDATA[private $cr_prices = false;]]></add>
</operation>
</file>
I've placed this file in vQmod's xml directory and am not using OCmod at all for this. It was fine at first, but later I had to refresh Opencart's modification cache for another xml that uses OCmod, and suddenly my entire page broke.
It turns out OCmod created a copy of system/library/cart.php using the modifications from my vQmod xml, and then vQmod made a modification of that file, duplicating all the modifications. So the above modification created these two lines:
private $cr_prices = false;
private $cr_prices = false;
And I got a PHP error about redeclaring class properties.
Anyone run into this problem before or know how to fix it? Why is OCmod applying changes that are in the vqmod/xml directory?
Heh, after hours of pouring through the core code turns out this wasn't really a problem with vQmod nor with OCmod themselves, but with an extension I used to install vQmod. I completely forgot I had installed vQmod using this extension...
I have uninstalled the extension and have installed vQmod via the official tutorial:
https://github.com/vqmod/vqmod/wiki/Installing-vQmod-on-OpenCart
Now things are working as they should.

vqmod doesn't create catalog/controller cache files

I'm trying to write my vqmod .xml, but nothing to work? if I try to add change in all catalog/* files. It works good for other (system/*, admin/*) files, but nothing changes? if I try to do something like this:
<file name="catalog/controller/checkout/cart.php">
<operation>
<search position="replace"><![CDATA[
$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
]]></search>
<add trim="true"><![CDATA[
$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
]]></add>
</operation>
</file>
what am I doing wrong?
Things to try:
Check whether vqmod is installed by calling
https://domain.com/vqmod/install in browser. If not installed, then
install and check.
Verify file name and path, also confirm that the code in search tag
exists in the file mentioned.
Check folder permissions. Make sure that vqmod/vqcache and
vqmod/logs have 755 or 777 permission. If nothing works, then try
777 permission recursively for vqmod folder.
Check the error logs in vqmod/logs.
Check the installed vqmod version and the vqmod version given in xml
file (<vqmver><![CDATA[version]]></vqmver>), both need to be the
same.
Delete the files in vqmod/vqcache and check again. Also see whether
vqmod copy of your file is generated or not.
Move any vqmod xml file outside the vqmod folder and check. If
everything works, move the xml back to the vqmod folder. I don’t
know the reason, but it worked for me in some cases :) !
<?xml version=”1.0″ encoding=”UTF-8″?> – put this line at the top of
the XML to make it valid and more compatible.
Try the VQMod Manager extension. It may help you!
Reference url: Opencart: Vqmod tutorial
Assuming the search can be found, you're not doing anything wrong. However, if it's only the catalog side that is having an issue, then it's most likely your opencart index.php for the catalog side doesn't have vQmod installed whereas the admin side does. Check your index.php file is correct. If that is written, then clear your vqcache folder to ensure it's actually writeable

Can partial config files linked to a web.config via configSource be transformed in a web project?

Looking for some help from anyone that's worked with SlowCheetah to transform config files under a web project. We're finding that partial config files referenced from the web.config are not being transformed.
For example, we've included references to partial configs AppSettings.config and ConnectionsString.config in the web.config like so:
</system.web>
<connectionStrings configSource ="ConnectionsString.config"></connectionStrings>
<appSettings configSource ="AppSettings.config"></appSettings>
</configuration>
and then in the AppSettings.config we have just the AppSettings section like so:
<appSettings>
<add key="LostPasswordBCC" value="knock#timmons.com" />
</appSettings>
and finally in the transform file AppSettings.Debug.config we have some additions:
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings >
<add key="Release" value="Something" xdt:Transform="Insert" />
</appSettings>
</configuration>
Obviously the above is just a test to see the transform occur, but what we're finding is that on attempting to preview the transform all we get back is an error "There was an error processing the transformation." The publish attempt also fails.
If we make the config files fully formed xml and not referenced from web.config, the transformation seems to work fine - but were looking to share these files across multiple projects.
Does anyone know if there's a workaround where we can both reference partial configs from the web.config and also have transforms off those partial files? We're dealing with legacy code with a large number of config files across multiple web projects that were attempting to consolidate, thus the need to link from web config to separate shared files.
Problem has been resolved, turns out after help from Sayed, we determined that in our efforts to understand the config transformation process with a web project we had corrupted the transform config file's format. With freshly created config files we were able to get transforms to work using SlowCheetah.
This allowed us to move on the real problem we needed to address which was wanting to transform project configs other than the web.config using Visual Studio 2012's publish profiles. This did not work originally, but again Sayed helped us out and provided a new copy of SlowCheetah that allowed this to work.
Below is a link to the new version of SlowCheetah with the fix: https://github.com/sayedihashimi/slow-cheetah/issues/46
Much thanks for all your time and patience Sayed.

Cookie Control Joomla Module - "no XML file"

I've been trying to install the Cookie Control Joomla module, I've tried all three methods of installing (Upload, Directory, URL). Each time I try it comes back with the error
"Error! Could not find a Joomla! XML setup file in the package."
There is definitely an XML file in the root, and I have downloaded from here:
http://www.joostrap.com/civic-cookie-control-joomla-module
Does anyone know of common errors for this or, why this maybe happening with this module?
I'm running Joomla v1.5 and have installed extensions before, but never with errors.
You are getting this error upon installation because the module is for Joomla 2.5, not 1.5.
Im not sure if converting the extension to 1.5 will still work, but could be worth a try. From what I can see, the only file you need to change is the XML.
<extension to <install
version="2.5" to version="1.5"
Remove the <config> tags
Remove <fields name="params">
Change <fieldset name="basic"> to <params>
Change all the <field> tags to <param>
Or you could have a look on the Joomla Extensions Directory for 1.5 compatible extensions

Create code coverage report starting at root folder

I have just created a new zend framework application to try out unit testing.
I have followed this tutorial and everything seems to be working correctly for testing. There is a problem with the display of the coverage report. It displays the correct information, but the report starts at the root of my hard drive and I need to traverse the tree to my project folder to see useful information.
This means that every time I ran the tests, I need to click 5 folders deep to get to the actual report.
How do I make the report start in my project folder? This is my phpunit config file:
<phpunit bootstrap="./bootstrap.php">
<testsuite name="Application Test Suite">
<directory>./application</directory>
</testsuite>
<testsuite name="Library Test Suite">
<directory>./library</directory>
</testsuite>
<filter>
<whitelist>
<directory>../../library/Zend</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
<file>../application/Bootstrap.php</file>
<file>../application/controllers/ErrorController.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
hightlight="true" lowupperbound="50" highlowerbound="80">
<log type="testdox" target="./log/testdox.html">
</log>
</log>
</logging>
</phpunit>
I fixed the problem...
I needed to explicitly specify my application folder in the whitelist. If it is empty, the code coverage report just starts from 'c:' and tries to find every '.php' file.
After adding the line in the whitelist section:
<directory>../application/</directory>
It works as expected.
Since I don't have any library tests in my test folder, including the Zend library folder probably had no effect and the report must have considered the whitelist empty. And because there is no blacklist, it just started from the root.
The code coverage starts at the most common path for all files included in the report. So if your web root is in /var/www and you include libraries in /usr/local/zend/ the most common path will be the root path.
The solution would be to exclude the library path because usually you don't want to measure the code coverage for external libraries anyway.