Another day another plugin (perhaps)…
I’ve meant to clean up all the link/href generating functions for a while now and finally I get around to start working on that. Nothing to get really excited about, as ideally, normal users shouldn’t even notice.
However, considering that zen_href_link and ZenMagick’s zm_href functions are used so frequently, it’s just natural to try and get them as effective as possible.
Right now there are two, in some cases, three functions involved that call each other in confusing ways…
And for good measure I plan to move the pretty link code into it’s own plugin, too. That would make three different SEO plugins - not a bad thing I think.
EDIT: The title turned out to be correct - there is now a new zm_pretty_links plugin. Another side effect of this is that the main .htaccess file is now obsolete and has been removed!
Similar to the htaccess_sample in the zm_seo2 plugin, there is now a sample file in the zm_pretty_links plugin which needs to be installed manually.
Unfortunately, I discovered a fatal bug redeeming gift certificates. If you are using the ZenMagick 0.8.4 or 0.8.5 you are most likely affected by this issue.
The main problem is that the code doesn’t break anything or create error messages. However, the redeemed amount is not credited to the users account.
I will release a bug fix update later today for people to update. If you think you can’t wait for that and feel comfortable enough with PHP, you can download a fixed version of ZMCoupons.php (zenmagick/core/services).
With 0.8.5 out of the way I think it is time for another iteration of performance measuring and improvements.
With the amount of new code there should be a few things I can do to make ZenMagick a bit faster.
One thing I’ll be looking at this time is to review the use of ‘zen-xxx’ functions. I tried to be as conservative as possible using them and in most cases there isn’t really the need other than some lazyness to write another service class.
Still, looking at the subversion files you can see that I have been experimenting with alternative init sequencenes (cutting out even more zen-cart code). This is not to drift further away from zen-cart, but to avoid loading and even executing code that is never used.
I wouldn’t expect this to work anytime soon, though. In particular, most of the mods that do work via ZenMagick plugins require the normal zen-cart init code in order to work properly.
Things I’ll be looking at are more like this:
- Found 2 lines of code using zen_xxx()
- zen_xxx() calls zen_yyy() and zen_zzz()
- none of the later are used anywhere else
- convert zen_xxx into either a service class, a new method of an existing class or a simple function
This is definitely going to improve a few things. For example, the new ZMTaxes class will help reduce database access by using internal caching (per request) and there are more cases like this.
This exercise will hopefully also give me a better idea of where most of the dependencies between zen-cart and ZenMagick are to be prepared for new releases…
For those interested, I fixed a bug in the PDF Order Centre today that will result in some HTML being displayed, if a coupon discount was redeemed.
The line in questions is line 430 in /admin/includes/modules/pdfoc/templates/Invoice.php
$pdf->ezText("<b>" . pdfoc_html_cleanup($order->totals[$i]['title']) . "</b>",PDFOC_TABLE_HEADER_FONT_SIZE,array('justification'=> 'right','aright'=>$x));
The coupon order total module has a link to the coupon help in the title which is printed verbatim. I changed this use a simple regular expression to remove any HTML links:
$title = preg_replace('/(.*)<a.*</a>/', '1', $order->totals[$i]['title']);
$pdf->ezText("<b>" . pdfoc_html_cleanup($title) . "</b>",PDFOC_TABLE_HEADER_FONT_SIZE,array('justification'=> 'right','aright'=>$x));
Just in case someone else out there is wondering too…
Just noticed that zen-cart 1.3.8 was released. i didn’t have time to look into the changes too deep, but I tried a *simple* upgrade of my local development system.
What I did in particular was:
- Copy all files on top of my zen-cart installation, effectively deleting all mod changes
- Ran the database upgrade
This failed the first time with SQL error updating the query_builder table, since query_keys_list didn’t allow NULL.
- Changed the database to allow NULL for column query_keys_list
- Ran the database upgrade again (succeeded, but with two ignored statements that I didn’t check)
- Logged in into admin
- Reapplied all ZenMagick file patches
- Done!
So far everything seems to work still fine. I’ll try to write more later once I had a chance to look into all the details of the changes