プロジェクト

全般

プロフィール

サポート #131

完了
廣僚 廣僚

サポート #5: AWSサーバー移管に伴う動作確認

酪農学園大学

サポート #131: 酪農学園大学

廣瀬 僚一 さんが2年以上前に追加. 2年以上前に更新.

ステータス:
終了
優先度:
通常
担当者:
開始日:
2023/12/18
期日:
2023/12/23
進捗率:

100%

予定工数:

説明

URL

https://www.rakuno.ac.jp

施行環境(ooda.biz)

施行環境でPDF生成プラグインのエラー修正を行うこと

確認事項

  • プラグイン更新
  • 不要なプラグイン削除
  • 全ページ エラーチェック
  • リンク切れチェック
  • 管理画面 エラーチェック
  • 管理画面 操作チェック
  • フォーム送信テスト

ファイル

ダウンロード.png (24 KB) ダウンロード.png アルドリノ デフリン, 2023/12/19 14:17
ダウンロード.png

関連するチケット 2 (0件未完了2件完了)

コピー元 酪農学園大学 - サポート #130: 酪農学園大学 短期大学部同窓会終了廣瀬 僚一2023/12/222023/12/22

操作
コピー先 酪農学園大学 - サポート #132: 入試課受験生サイト終了廣瀬 僚一2023/12/232023/12/23

操作

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #1

  • コピー元 サポート #130: 酪農学園大学 短期大学部同窓会 を追加

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #2

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #3

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #4

  • 担当者廣瀬 僚一 から アルドリノ デフリン に変更
  • 開始日2023/12/23 から 2023/12/18 に変更

@アルドリノ デフリン
事前チェックとして、
施行環境(ooda.biz)php8.1の環境で、PDF生成のプラグインが動作するように調整をお願いします

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #5

  • ステータス新規 から 進行中 に変更
  • 進捗率0 から 30 に変更

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #6

以下TCPDFとPHPのバージョンが合わないためエラー

Fatal error: Array and string offset access syntax with curly braces is no longer supported in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/plugin/pdf/lib/tcpdf/tcpdf.php on line 16900

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #7

ダウンロード.png

TCPDFFPDIの新しいバージョンと入れ替える
FPDIはTCPDFのディレクトリー内に配置

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #8

func_pdf.phpmake_pdf関数から以下のエラー

Warning: require_once(/home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/../plugin/pdf/lib/tcpdf/fpdi/fpdi.php): Failed to open stream: No such file or directory in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_pdf.php on line 29

Fatal error: Uncaught Error: Failed opening required '/home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/../plugin/pdf/lib/tcpdf/fpdi/fpdi.php' (include_path='.:/opt/php-8.1.22/data/pear') in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_pdf.php:29 Stack trace: #0 /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/page-pdf.php(7): make_pdf('16299', 'pdf') #1 /home/clddev/ooda.biz/public_html/rgu/wp-includes/template-loader.php(106): include('/home/clddev/oo...') #2 /home/clddev/ooda.biz/public_html/rgu/wp-blog-header.php(19): require_once('/home/clddev/oo...') #3 /home/clddev/ooda.biz/public_html/rgu/index.php(17): require('/home/clddev/oo...') #4 {main} thrown in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_pdf.php on line 29

新しいバージョンのTCPDFとFPDIなのでディレクトリー構造も変わっているので
以下に変更:
修正前:

  require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/tcpdf.php');
  require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/fpdi/fpdi.php');

修正後:

require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/tcpdf.php');
require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/fpdi/src/autoload.php');

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #9

パス変更したら以下のエラーに変わった

Fatal error: Uncaught Error: Class "FPDI" not found in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_pdf.php:76 Stack trace: #0 /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/page-pdf.php(7): make_pdf('16299', 'pdf') #1 /home/clddev/ooda.biz/public_html/rgu/wp-includes/template-loader.php(106): include('/home/clddev/oo...') #2 /home/clddev/ooda.biz/public_html/rgu/wp-blog-header.php(19): require_once('/home/clddev/oo...') #3 /home/clddev/ooda.biz/public_html/rgu/index.php(17): require('/home/clddev/oo...') #4 {main} thrown in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_pdf.php on line 76

公式ドキュメントにより以下を追加
require_onceの後に追加
useは関数内で定義できないので、2つのrequire_onceと一緒にファイルの頭に記載

require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/tcpdf.php');
require_once(__DIR__ . '/../plugin/pdf/lib/tcpdf/fpdi/src/autoload.php');

use setasign\Fpdi\Tcpdf\Fpdi;

//PDF作成
function make_pdf($sid, $flg)
{

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #10

管理画面で以下のエラー
投稿一覧画面

Notice: 関数 WP_Object_Cache::add が誤って呼び出されましたキャッシュキーは空の文字列にはできません 詳しくは WordPress のデバッグをご覧ください (このメッセージはバージョン 6.1.0 で追加されました) in /home/clddev/ooda.biz/public_html/rgu/wp-includes/functions.php on line 6031

投稿新規追加・編集画面

Warning: Undefined variable $type in /home/clddev/ooda.biz/public_html/rgu/wp-content/plugins/feedwordpress/feedwordpress.php on line 2292

どちらもコアファイルなので修正不可。WP_DEBUGFalseにすれば消える。

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #11

ページ サークル

Warning: Undefined variable $tourism in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history.php on line 68

シングル 研究シーズ

Warning: Undefined variable $tourism in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_seedslist.php on line 68

シングル 教員・研究室

Warning: Undefined variable $tourism in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_history.php on line 68

原因

変数の初期値設定がなかったため

function readpost_typecheack($postnum)
{
  $postdate = readpost();
  $numlist = 0;

  if (!empty($postdate)) :
    foreach ($postdate as $key => $val) :
      $posttype = get_post_type($val);
      if ($posttype === "club") :
        if ($postnum == $numlist) {
          break;
        }
        $tourism[] = $val;
        $numlist++;
      endif;
    endforeach;
  endif;

  return $tourism; // ← $postdate が空の時、変数が定義されていないためエラー
}
?>

解決策

初期値を設定
readpost_typecheack_teacher、readpost_typecheack_seedslist も同じ修正

function readpost_typecheack($postnum)
{
  $postdate = readpost();
  $tourism = array(); // <-- 追加
  $numlist = 0;
  
}

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #12

ユーザー画面 ページ 研究シーズ

Warning: Undefined array key "slug" in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/page-seedslist.php on line 30

ユーザー画面 ページ 教員・研究室一覧

Warning: Undefined array key "slug" in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/page-teacher.php on line 50

原因

GET パラメータが設定されていない時の判定がなかったため

$get_dept = $_GET['slug'];

解決策

判定を追加

$get_dept = isset($_GET['slug']) ? $_GET['slug'] : null;

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #13

サークルのページ・シングル、研究シーズのシングル、教員のシングルで
以下似ているエラー

ページ サークル

Warning: Undefined array key "postid_history" in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history.php on line 40
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history.php on line 40

シングル 研究シーズ

Warning: Cannot modify header information - headers already sent by (output started at /home/clddev/ooda.biz/public_html/rgu/wp-content/plugins/all-in-one-seo-pack/app/Common/Main/Title.php:63) in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_seedslist.php on line 32
Warning: Undefined array key "postid_history" in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_seedslist.php on line 40
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_seedslist.php on line 40

シングル 教員・研究室

Warning: Cannot modify header information - headers already sent by (output started at /home/clddev/ooda.biz/public_html/rgu/wp-content/plugins/all-in-one-seo-pack/app/Common/Main/Title.php:63) in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_teacher.php on line 32
Warning: Undefined array key "postid_history" in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_teacher.php on line 40
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/clddev/ooda.biz/public_html/rgu/wp-content/themes/rgu/inc/func_history_teacher.php on line 40

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #14

原因 ①

Undefined array key "postid_history"Passing null to parameter は、
func_history.php、func_history_seedslist.php、func_history_teacher.php の
以下で postid_history が設定されていない時のバリデーションがなかったため。

$postread = explode(",", $_COOKIE['postid_history']);

解決策 ①

判定を追加

$postid_history = isset($_COOKIE['postid_history']) ? $_COOKIE['postid_history'] : "";
$postread = explode(",", $postid_history);

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #15

原因 ②

Cannot modify header information は、ヘッダーを 2 回送信しようとしていたのでエラー

add_action('get_header', 'readpost');
function readpost() {
  
  setcookie('postid_history', $set_this_ID, time() + 60 * 60 * 24 * 365 * 1, '/');
  
}

1 回目のヘッダー送信:add_action("get_header", "readpost");
2 回目のヘッダー送信:setcookie 関数
クッキーの値を取得するために readpost 関数はページ・シングル内で使われているので結果的にヘッダーを 2 回送信。

解決策 ②

まとまっっていた関数を 2 つに分ける。一つはクッキーを設定用で、もう一つはクッキーを取得用。

/**
 * クッキーを設定
 * @return void
 */
add_action('get_header', 'set_postid_history_cookie');
function set_postid_history_cookie()
{
  if (is_single()) {
    $browsing_histories = isset($_COOKIE['postid_history']) ? explode(",", $_COOKIE['postid_history']) : array();

    if (!in_array(get_the_ID(), $browsing_histories)) {
      array_unshift($browsing_histories, get_the_ID());
    }

    if (count($browsing_histories) >= 50) {
      $browsing_histories = array_slice($browsing_histories, 0, 49);
    }

    $new_cookie_value = implode(",", $browsing_histories);
    setcookie('postid_history', $new_cookie_value, time() + 60 * 60 * 24 * 365 * 1, '/');
  }
}

/**
 * クッキーを取得
 * @return array $postids 投稿IDの配列
 */
function get_postid_history_cookie()
{
  $postid_history = isset($_COOKIE['postid_history']) ? $_COOKIE['postid_history'] : "";
  $postids = explode(",", $postid_history);
  $postids = array_unique($postids);
  $postids = array_values($postids);
  return $postids;
}

追加変更

func_history.php、func_history_seedslist.php、func_history_teacher.php で
シングルページからクッキーの値を取得する用の関数以外は同じなので全て func_history.php で共通化。
投稿タイプしか変わらないので関数の引数を追加。
関数名と変数名も変更(分かりやすくするため)。
不要の HTML タグも削除。

// 修正前
function readpost_typecheack($postnum)
{
  $postdate = readpost();
  $tourism = [];
  $numlist = 0;

  if (!empty($postdate)) :
    foreach ($postdate as $key => $val) :
      $posttype = get_post_type($val);
      if ($posttype === "club") :
        if ($postnum == $numlist) {
          break;
        }
        $tourism[] = $val;
        $numlist++;
      endif;
    endforeach;
  endif;

  return $tourism;
}
// 修正後
function get_recent_history($postnum, $pt = 'post')
{
  $postdate = get_postid_history_cookie();
  $tourism = array();
  $numlist = 0;

  if (!empty($postdate)) :
    foreach ($postdate as $val) :
      $posttype = get_post_type($val);
      if ($posttype === $pt) :
        if ($postnum == $numlist) {
          break;
        }
        $tourism[] = $val;
        $numlist++;
      endif;
    endforeach;
  endif;

  return $tourism;
}

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #16

検索 研究シーズ
検索 教員
ページネーションが動いていない
TOPページにリダイレクトされる

原因

投稿の表示数の設定に不一致があったため
functions.php では投稿表示数を30件に設定していたが、
search-seedslist.phpsearch-teacher.php では15件に指定されていた。

// functions.php
add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts($query)
{
  $today = date_i18n('Y-m-d');
  
  if (is_admin() || !$query->is_main_query()) return;
  if ($query->is_archive()) {
    $query->set('posts_per_page', 30); // ⇐ ここ
  }
  
}

// search-seedslist.php と search-teacher.php
$search_query = get_search_query();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
  'paged' => $paged,
  'posts_per_page' => 15, // ⇐ とここ
  'post_status' => 'publish',
  'post_type' => 'seedslist',
  'orderby' => 'date',
  'order' => 'DESC',
  's' => $search_query
);
$wp_query = new WP_Query($args);

解決策

functions.php の関数を修正し、投稿のアーカイブと検索結果の表示件数を調整

add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts($query) {
  $today = date_i18n('Y-m-d');
  $post_type = get_query_var('post_type');

  if (is_admin() || !$query->is_main_query()) return;
  if ($query->is_archive()) {
    if ($post_type === "seedslist" || $post_type === "teacher") {
      $query->set('posts_per_page', 15);
    } else {
      $query->set('posts_per_page', 30);
    }
  }
  
}

追加変更

クエリの処理をプラグインに移行したので、
search-seedslist.phpsearch-teacher.php にあるクエリの記述は全て削除。

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #17

  • ステータス進行中 から フィードバック に変更
  • 担当者アルドリノ デフリン から 廣瀬 僚一 に変更

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #18

  • 担当者廣瀬 僚一 から アルドリノ デフリン に変更

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #19

  • ステータスフィードバック から 進行中 に変更

アデ アルドリノ デフリン さんが2年以上前に更新 操作 #20

  • ステータス進行中 から フィードバック に変更
  • 担当者アルドリノ デフリン から 廣瀬 僚一 に変更

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #21

  • ステータスフィードバック から 解決 に変更
  • 進捗率30 から 90 に変更

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #22

障害

DNS切り替え後にTOPページのみ読み込みが遅くなり、504タイムアウトエラーが発生。
TOPページが表示できなくなる状態となった。

要因

よく検索されているキーワード の表示で遅延発生していた。
キーワードは、運用開始以来データが溜まり続けている状態で、データベース上に140万レコード近くデータ保管されていた。

対応

phpでwp_search テーブルのすべてのデータをtruncateする処理を実施(デフリン対応)。
inc/func_keyword.php

function truncate_Keyword()
{
  global $wpdb;

  $table_name = $wpdb->prefix . "search";
  $sql = "TRUNCATE TABLE `$table_name`";

  $wpdb->query($sql);
}

今後定期的にデータをリセットする運用にする必要があることを、北海道リハビリー山本さんへ連絡。
↑上記内容を酪農学園にも連絡されていること確認した。

備考

以前のサーバー、テスト環境でも動作していたことを確認している。
DNS切り替え後に、発生したことを考えるとサーバー側の要因(スペックなど)も考えられる。

廣僚 廣瀬 僚一 さんが2年以上前に更新 操作 #23

  • ステータス解決 から 終了 に変更
  • 進捗率90 から 100 に変更

他の形式にエクスポート: PDF Atom