<em class="placeholder">InvalidArgumentException</em>: Placeholders must have a trailing [] if they are to be expanded with an array of values. in <em class="placeholder">Drupal\Core\Database\Connection-&gt;expandArguments()</em> (line <em class="placeholder">729</em> of <em class="placeholder">core/lib/Drupal/Core/Database/Connection.php</em>). <pre class="backtrace">Drupal\Core\Database\Connection-&gt;query(&#039;SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid&#039;, Array, Array) (Line: 87)
Drupal\Core\Database\Driver\mysql\Connection-&gt;query(&#039;SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid&#039;, Array, Array) (Line: 61)
db_query(&#039;SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid&#039;, Array) (Line: 15)
_linkchecker_batch_import_nodes(Array) (Line: 369)
Drupal\linkchecker\Form\LinkCheckerAdminSettingsForm-&gt;submitAnalyzeLinks(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter-&gt;executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter-&gt;doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;linkchecker_admin_settings&#039;, Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;linkchecker_admin_settings&#039;, Object) (Line: 74)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>

Comments

Jorge Navarro created an issue. See original summary.

hass’s picture

Category: Bug report » Task

Please share a patch.

siva01’s picture

There is patch, which should solve it. Problem is at outdated database queries.

hass’s picture

Status: Active » Needs work
  1. +++ b/linkchecker.batch.inc
    @@ -12,11 +12,16 @@ use \Drupal\node\Entity\Node;
    -    $operations[] = ['_linkchecker_batch_node_import_op', [$row->nid]];
    +    $operations[] = ['_linkchecker_batch_node_import_op', [$row]];
    

    This looks not correct.

  2. +++ b/linkchecker.module
    @@ -1314,11 +1314,21 @@ function _linkchecker_add_node_links($node, $skip_missing_links_detection = FALS
             $link->status = _linkchecker_link_check_status_filter($url);
    -        drupal_write_record('linkchecker_link', $link);
    +
    +
    +        $connection->insert('linkchecker_link')
    +          ->fields([
    +            'urlhash' => $urlhash,
    +            'url' => $url,
    +            'status' => _linkchecker_link_check_status_filter($url)
    +          ])
    +          ->execute();
    +
    +
    

    I guess this need to be a merge query. With inserts this could lead to duplicate entry issues.

shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
shubhangi1995’s picture

StatusFileSize
new1.33 KB

hi @hass,
doubts from your side:
1) - $operations[] = ['_linkchecker_batch_node_import_op', [$row->nid]];
+ $operations[] = ['_linkchecker_batch_node_import_op', [$row]];

here $row is being used at place of the nid of the nodes which are of the CT for which lick checking is to be done, I think this is what we require as the operation function is also loading the node on the basis of variable from $row only. If my understanding is wrong and we require a value other than node id please let me know.

2) drupal_write_record('linkchecker_link', $link);
+
+
+ $connection->insert('linkchecker_link')
+ ->fields([
+ 'urlhash' => $urlhash,
+ 'url' => $url,
+ 'status' => _linkchecker_link_check_status_filter($url)
+ ])
+ ->execute();

will not be leading to duplication as in case of linkchecker_link table first it looks for the specific hash if not found then only it inserts the link object in table

Updation in patch:

1) removal of status colunm as its missing in Drupal 8 node table.
2) addition of new variable lid as the the old variable link dint had lid assigned to it.

if everything fine please mention areas where work is left related to this module.

shubhangi1995’s picture

Status: Needs work » Needs review
hass’s picture

I have not tested, but I guess it need to be $row->id() - at least we need the node id and not the complete database row. _linkchecker_batch_node_import_op() function expects to get the node id.

removal of status colunm as its missing in Drupal 8 node table.

We need to make sure a node is only scanned if it is pulished. If status has been moved somewhere else we need to get the info from there.

shubhangi1995’s picture

StatusFileSize
new1017 bytes

Hi @hass
the [row] is sending the node id only hence is according to requirement and have updated the patch so that we check the status too please review.

shubhangi1995’s picture

StatusFileSize
new4.25 KB

final patch according to the changes recommended

waverate’s picture

Status: Needs review » Needs work

Patch at #10 does not apply cleanly against 8.x-1.x-dev (Last updated: 31 Oct 2018 at 07:28 EDT).

[server-1 linkchecker]$ patch -p2 < linkchecker-2960416-19.patch
(Stripping trailing CRs from patch; use --binary to disable.)
patching file linkchecker.module
Hunk #1 FAILED at 607.
1 out of 4 hunks FAILED -- saving rejects to file linkchecker.module.rej
(Stripping trailing CRs from patch; use --binary to disable.)
patching file linkchecker.batch.inc
[server-1 linkchecker]$ 

It probably needs to be re-rolled.

hass’s picture

Status: Needs work » Fixed

I guess this issue is resolved in latest dev. Please test.

shubhangi1995’s picture

yes it worked , thanks

hass’s picture

Title: Query error when executing linkcheker » Query error when executing linkchecker

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.