Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIv4 - Emit notices about deprecated join aliases #20716

Merged

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jun 27, 2021

Overview

Gives notices from APIv4 to alert developers to update their join syntax if needed.
Switches internal API calls and unit tests to use the non-deprecated syntax.

Old Syntax

civicrm_api4('Contact', 'get', [
  'select' => ['employer.display_name'],
]);

New Syntax

civicrm_api4('Contact', 'get', [
  'select' => ['employer_id.display_name'],
]);

Technical Details

Now using e.g. employer instead of employer_id will emit deprecation notice.
The aliases were deprecated a few months ago to reduce ambiguity, as not every FK field ends in "_id".
See #20130

@civibot
Copy link

civibot bot commented Jun 27, 2021

(Standard links)

@civibot civibot bot added the master label Jun 27, 2021
@colemanw colemanw force-pushed the emitApi4NoticesAboutDeprecatedJoinAliases branch 2 times, most recently from 0408d32 to c0f9cc6 Compare June 27, 2021 19:36
@seamuslee001
Copy link
Contributor

@colemanw

It hard failed in api_v3 tests

PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /home/jenkins/bknix-dfl/build/core-20716-4ex7n/web/sites/all/modules/civicrm/CRM/Utils/API/HTMLInputCoder.php on line 136
PHP Stack trace:
PHP   1. {main}() /home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar:0
PHP   2. PHPUnit\TextUI\Command::main() /home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar:671
PHP   3. PHPUnit\TextUI\Command->run() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/TextUI/Command.php:101
PHP   4. PHPUnit\TextUI\TestRunner->doRun() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/TextUI/Command.php:129
PHP   5. PHPUnit\Framework\TestSuite->run() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/TextUI/TestRunner.php:462
PHP   6. PHPUnit\Framework\TestSuite->run() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestSuite.php:481
PHP   7. api_v3_OrderTest->run() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestSuite.php:481
PHP   8. PHPUnit\Framework\TestResult->run() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestCase.php:662
PHP   9. api_v3_OrderTest->runBare() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestResult.php:577
PHP  10. api_v3_OrderTest->runTest() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestCase.php:888
PHP  11. api_v3_OrderTest->runTest() /home/jenkins/bknix-dfl/build/core-20716-4ex7n/web/sites/all/modules/civicrm/tests/phpunit/CiviTest/CiviUnitTestCase.php:256
PHP  12. api_v3_OrderTest->testGetOrderParticipant() phar:///home/jenkins/bknix-dfl/extern/phpunit8/phpunit8.phar/phpunit/Framework/TestCase.php:1212
PHP  13. api_v3_OrderTest->createPartiallyPaidParticipantOrder() /home/jenkins/bknix-dfl/build/core-20716-4ex7n/web/sites/all/modules/civicrm/tests/phpunit/api/v3/OrderTest.php:95

but also looks like there are some failures in the api_v4_AllTests suite as well

@colemanw colemanw force-pushed the emitApi4NoticesAboutDeprecatedJoinAliases branch from 90addff to 26a7b54 Compare June 28, 2021 18:21
@colemanw colemanw force-pushed the emitApi4NoticesAboutDeprecatedJoinAliases branch 4 times, most recently from c1c648b to 8be92a5 Compare June 29, 2021 04:23
Updates APIv4 calls in CiviCRM core to use e.g. `event_id.title` instead of `event.title`
@colemanw colemanw force-pushed the emitApi4NoticesAboutDeprecatedJoinAliases branch from 8be92a5 to 84ad769 Compare June 29, 2021 12:49
@seamuslee001
Copy link
Contributor

This seems fine to merging

@seamuslee001 seamuslee001 merged commit 77788ec into civicrm:master Jun 29, 2021
@seamuslee001 seamuslee001 deleted the emitApi4NoticesAboutDeprecatedJoinAliases branch June 29, 2021 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants