Skip to content

Commit

Permalink
Civi\Angular\ChangeSet - Relax debug-mode consistency check
Browse files Browse the repository at this point in the history
Overview
--------

The Angular subsystem *sometimes* includes a consistency-check. The consistency check ensures that an HTML document is
read/written in consistency format (i.e. `encode(decode($html)) === $html`). However, the check is not often run, and
it sometimes produces errors on consistency issues which we don't care about.

This approach here is to relaxes the checks in `civicrm-core` and reproduce them in separate developer-oriented tooling.

Before
------

* If an Angular HTML partial is not altered (`hook_civicrm_alterAngular`), then the partial is *not* checked for consistency.
* If a site is in production/non-debug mode, then the partial is *not* checked for consistency.
* If a site is in debug mode, then the partial *is* checked for consistency.

After
-----

* The partial is not checked for consistency.
* A task is recorded on the [Afform roadmap](https://github.com/totten/afform/blob/master/docs/roadmap.md) to include
  better consistency checks in the `afform_auditor` extension.
  • Loading branch information
totten committed Jun 13, 2019
1 parent 5976ea1 commit 69b7411
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions Civi/Angular/ChangeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ private static function applyHtmlFilters($changeSets, $strings) {
if (preg_match($filter['regex'], $path)) {
if ($doc === NULL) {
$doc = \phpQuery::newDocument($html, 'text/html');
if (\CRM_Core_Config::singleton()->debug && !$coder->checkConsistentHtml($html)) {
throw new \CRM_Core_Exception("Cannot process $path: inconsistent markup. Use check-angular.php to investigate.");
}
}
call_user_func($filter['callback'], $doc, $path);
}
Expand Down

0 comments on commit 69b7411

Please sign in to comment.