If there are no content types with newsletter enabled, then when running a simplenews cron job, "Call to a member function getColumns on boolean" is triggered by an entity query:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zenimagine created an issue. See original summary.

jonathanshaw’s picture

Title: Error when a cron job is started » "Call to a member function getColumns on boolean" in simplenews entity query
Priority: Critical » Major
Issue summary: View changes
myriam_b’s picture

Do you find a solution ?

GiorgosK’s picture

subson’s picture

in cron run, updateSendStatus() gets called which has below query, but I couldn't find any reference to this field simplenews_issue.status in any tables. Can somebody help explain how and from where this field is used? This query is causing the issue.

$nids = $query
->condition('simplenews_issue.status', SIMPLENEWS_STATUS_SEND_PENDING)
->execute();

and this field_storage in simplenews_form_node_type_submit() is returning NULL before FieldConfig::create();
$field_storage = FieldStorageConfig::loadByName('node', 'simplenews_issue');

I guess this needs to be created somewhere.

AdamPS’s picture

Priority: Major » Normal

It looks like the code

$nids = $query
->condition('simplenews_issue.status', SIMPLENEWS_STATUS_SEND_PENDING)
->execute();

needs to change to

$nids = $query
->condition('simplenews_issue.simplenews_issue_status', SIMPLENEWS_STATUS_SEND_PENDING)
->execute();

The issue summary doesn't make it clear what the consequences are. Looking at the code in simplenews_cron I would expect that newsletters are still sent, so it doesn't seem like "Major" priority.

marshy_b_2101’s picture

I'm experiencing the same issue.
Using 8.x-1.0-beta1.

When I attempt to uninstall simplenews via the interface I see:

The following reasons prevent Simplenews from being uninstalled:

There is content for the entity type: Simplenews subscriber. Remove simplenews subscriber entities.
The Simplenews issue field type is used in the following field: node.simplenews_issue
The Simplenews subscription field type is used in the following field: simplenews_subscriber.subscriptions

Additionally, when I attempt to Remove simplenews subscriber entities I geth the following php error:

Uncaught PHP Exception InvalidArgumentException: "The controller for URI "" is not callable." at /mnt/www/html/blahblahblah/docroot/core/lib/Drupal/Core/Controller/ControllerResolver.php...

AdamPS’s picture

#7 is not the same issue - this issue is about running cron. There is a page to prepare for uninstall /admin/config/services/simplenews/settings/uninstall.

vuil’s picture

vuil’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 9: 2889976-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

AdamPS’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev

Thanks @ilchovuchkov. Yes you are exactly right that new patches should be for 2.x so I updated the version on the issue. It is sufficient to test with the default test settings so that might save you time instead of running 5 tests.

marshy_b_2101’s picture

Apologies. I understand the uninstall issue is different. I had intended to leave additional info. Not sure where I went wrong.
I attempted uninstall in the first place because I'm receiving:

4 /mnt/www/html/blahblahblah/docroot/modules/contrib/simplenews/simplenews.module(313): Drupal\simplenews\Mail\Mailer->updateSendStatus()
#3 /mnt/www/html/blahblahblah/docroot/modules/contrib/simplenews/src/Mail/Mailer.php(403): Drupal\Core\Entity\Query\Sql\Query->execute()
#2 /mnt/www/html/blahblahblah/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(80): Drupal\Core\Entity\Query\Sql\Query->compile()
#1 /mnt/www/html/blahblahblah/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(172): Drupal\Core\Entity\Query\Sql\Condition->compile(Object(Drupal\Core\Database\Driver\mysql\Select))
[09-Aug-2019 14:07:00 UTC] Error: Call to a member function getColumns() on boolean in /mnt/www/html/neiud8/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php on line 252 #0 /mnt/www/html/neiud8/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(52): Drupal\Core\Entity\Query\Sql\Tables->addField('simplenews_issu...', 'INNER', NULL)

pminf’s picture

@marshy_b_2101 Please have a look at https://www.drupal.org/project/simplenews/issues/2773403 or open a separate issue about your error during uninstall.

pminf’s picture

The Patch from #9 solved this cron issue for me. Not sure why so many tests failed. Could someone please have a look?

jonathanshaw’s picture

Maybe because the issue was marked as being against 1.x but the patch needs 2.x; I've queued for retest, let's see if that does it.

pminf’s picture

Sorry, I was probably too hasty, because the error still persists. Patch from #9 does not solve this cron issue for me.

geek-merlin’s picture

AdamPS’s picture

The IS still doesn't describe the sequence of steps to reproduce the bug.

From a PHP shell I can run the command without any problem

\Drupal::entityQuery('node')->condition('simplenews_issue.status', SIMPLENEWS_STATUS_SEND_PENDING)->execute();

Perhaps the bug is only seen with an unusual or corrupted state of field storage or field data?

4kant’s picture

Maybe this helps someone:

  1. I had the same error message on cron run.
  2. When I tried to uninstall simplenews I got the error message mentioned by #7:
    "Simplenews can not be uninstalled. The Simplenews subscription field type is used in the following field: simplenews_subscriber.subscriptions"
  3. Then I deleted this field -->
  4. successfully uninstalled Simplenews -->
  5. successfully ran cron

Last week I had deleted the content type Newsletter Issue - I guess that was the source. Simplenews-Module isn't needed in this project anymore.

AdamPS’s picture

Title: "Call to a member function getColumns on boolean" in simplenews entity query » Cron fails if there are no content types with newsletter enabled
Version: 8.x-2.x-dev » 3.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs steps to reproduce

I hit this on a site today so I now understand how to reproduce it. The problem occurs if there are no content types with newsletter enabled in which case the simplenews_issue field doesn't exist.

AdamPS’s picture

So this is the same as #2974147: Once all newsletter content types have been deleted cannot create a new one - the patch there will ensure that the field storage persists so this will no longer be a problem