Commit 7126e544 authored by drumm's avatar drumm
Browse files

Do not assume field_project_type exists

parent 47d863a0
......@@ -218,10 +218,9 @@ function drush_project_release_release_create_history($project_id = NULL) {
}
else {
// Generate all xml files for projects with releases.
$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
$result = (new EntityFieldQuery())->entityCondition('entity_type', 'node')
->entityCondition('bundle', project_project_node_types())
->fieldCondition('field_project_type', 'value', 'full')
->fieldCondition('field_project_has_releases', 'value', TRUE)
->execute();
if (!empty($result)) {
foreach (array_chunk(array_keys($result['node']), variable_get('project_release_history_batch_size', 100)) as $nids) {
......
......@@ -91,7 +91,7 @@ function project_release_menu_alter(&$callbacks) {
*/
function project_release_project_settings_form_access($node) {
$wrapper = entity_metadata_wrapper('node', $node);
if (!variable_get('project_release_sandbox_allow_release', TRUE) && $wrapper->field_project_type->value() === 'sandbox' && !$wrapper->field_project_has_releases->value()) {
if (!variable_get('project_release_sandbox_allow_release', TRUE) && project_promote_project_is_sandbox($node) && !$wrapper->field_project_has_releases->value()) {
return FALSE;
}
else {
......@@ -705,7 +705,7 @@ function project_release_node_validate(&$node, $form, &$form_state) {
if (project_node_is_project($node)) {
// If sandbox projects are configured to not allow releases, and this is a
// sandbox project, force the 'has project releases' setting to unchecked.
if (!variable_get('project_release_sandbox_allow_release', TRUE) && $node->field_project_type[LANGUAGE_NONE][0]['value'] === 'sandbox') {
if (!variable_get('project_release_sandbox_allow_release', TRUE) && project_promote_project_is_sandbox($node)) {
if (!empty($form_state['values']['field_project_has_releases'][LANGUAGE_NONE][0]['value'])) {
unset($form_state['input']['field_project_has_releases']);
form_set_value($form['field_project_has_releases'][LANGUAGE_NONE], [0 => ['value' => 0]], $form_state);
......
......@@ -76,7 +76,7 @@ function project_usage_retrieve_metadata() {
// Load information about projects.
$result = (new EntityFieldQuery())->entityCondition('entity_type', 'node')
->entityCondition('bundle', project_project_node_types())
->fieldCondition('field_project_type', 'value', 'full', '=')
->fieldCondition('field_project_has_releases', 'value', TRUE)
->execute();
if (isset($result['node'])) {
foreach (array_chunk(array_keys($result['node']), 200) as $project_nids) {
......
......@@ -52,11 +52,8 @@ class project_plugin_argument_validate_project_nid extends views_plugin_argument
function limit_query_to_project($query) {
$query
// Projects are currently restricted to nodes!
->entityCondition('entity_type', 'node')
// If there is a field_project_type, this is a project.
// This part is what we care about.
->fieldCondition('field_project_type', 'value', NULL, 'IS NOT NULL');
->propertyCondition('type', project_project_node_types());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment